Allow setting IP to listen on.

Running on bare metal, 127.0.0.1 is a sensible choice of address
to bind on, but that is not the case when running inside a
container, so we add the ability to choose which IP to listen on.

This can be given via the environment variable HTTP_HOST when
starting the server or, if used as a module, as the second
argument of the start(port, host, path) function.
This commit is contained in:
D. Berge
2023-04-07 09:04:51 +02:00
parent 5a44e20a5b
commit 6d8a199a3c
2 changed files with 9 additions and 7 deletions

View File

@@ -13,7 +13,10 @@ async function main () {
const { fork } = require('child_process');
const server = api.start(process.env.HTTP_PORT || 3000, process.env.HTTP_PATH);
const port = process.env.HTTP_PORT || 3000;
const host = process.env.HTTP_HOST || "127.0.0.1";
const path = process.env.HTTP_PATH;
const server = api.start(port, host, path);
ws.start(server);
const eventManagerPath = [__dirname, "events"].join("/");