Stream: ideas

Topic: basic-webserver configuration


view this post on Zulip Luke Boswell (May 27 2024 at 23:04):

I need to modify basic webserver so that it can take arguments or configuration on startup. I was just wondering if anyone has any thoughts on this?

The easiest thing is to just make command line arguments as required.

But I was wondering if there are other options we might want to consider?

view this post on Zulip Luke Boswell (May 27 2024 at 23:05):

Specifically I think I need to be able to listen to 0.0.0.0 instead of just localhost for use within a Docker container.

view this post on Zulip Hannes (May 28 2024 at 00:28):

I was trying to use a different port with basic-webserver yesterday, would be nice to have some way to configure it :+1:

view this post on Zulip Brendan Hansknecht (May 28 2024 at 01:00):

Probably should be a config file or environment variable

view this post on Zulip Richard Feldman (May 28 2024 at 01:00):

I think probably the best path here is too finally make it possible to request multiple functions from the app, and also to allow exposing multiple functions to the host

view this post on Zulip Brendan Hansknecht (May 28 2024 at 01:00):

Cause you would want to change it based on CI vs prod without changing any roc code

view this post on Zulip Richard Feldman (May 28 2024 at 01:08):

I think we could do that for now to unblock, but in general I definitely think platforms should not depend on env vars

view this post on Zulip Richard Feldman (May 28 2024 at 01:09):

rather, they should explicitly ask the app for all config, and if the app wants to use env vars to configure their own config, that's up to them

view this post on Zulip Richard Feldman (May 28 2024 at 01:10):

e.g. in addition to main, apps also are asked to expose init : EnvVars -> Config or something like that

view this post on Zulip Richard Feldman (May 28 2024 at 01:10):

and the server calls that once on startup

view this post on Zulip Richard Feldman (May 28 2024 at 01:11):

and Config includes things like port etc

view this post on Zulip Luke Boswell (May 28 2024 at 01:31):

I could probably hack that into the main API, and still keep the mainForHost API unchanged. I could hardcode a "Request" and "Response" for doing that, and expose an additional init to the application.

view this post on Zulip Luke Boswell (May 28 2024 at 01:31):

We could clean it up later and update the mainForHost part to have multiple functions exposes to the host

view this post on Zulip Luke Boswell (May 28 2024 at 01:33):

So apps won't need to change in the future, and we don't have the platform relying on an ENV Var. Just the host<->platform part of the API is a little more complicated than required.

view this post on Zulip Luke Boswell (May 28 2024 at 02:11):

It's probably too hacky I think

view this post on Zulip Luke Boswell (May 28 2024 at 03:27):

Oh, they already are Evironment variables... I only just realised.

$ ROC_BASIC_WEBSERVER_HOST=0.0.0.0 ROC_BASIC_WEBSERVER_PORT=9090 roc examples/hello-web.roc
🔨 Rebuilding platform...
Listening on <http://0.0.0.0:9090>

Last updated: Jun 16 2026 at 16:19 UTC