diff --git a/.config/example.yml b/.config/example.yml index ffc8a1d346..6b8c7e2e5f 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -29,6 +29,10 @@ url: https://example.com/ # The port that your Firefish server should listen on. port: 3000 +# The bind host your Calckey server should listen on. +# If unspecified, the wildcard address will be used. +#bind: 127.0.0.1 + # ┌──────────────────────────┐ #───┘ PostgreSQL configuration └──────────────────────────────── diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index bbefdc34ca..f2e8630ade 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -106,7 +106,11 @@ export async function masterMain() { config = loadConfigBoot(); await connectDb(); } catch (e) { - bootLogger.error("Fatal error occurred during initialization", null, true); + bootLogger.error( + `Fatal error occurred during initialization: ${e}`, + null, + true, + ); process.exit(1); } diff --git a/packages/backend/src/config/load.ts b/packages/backend/src/config/load.ts index 7a67c4bd32..d8dea793e9 100644 --- a/packages/backend/src/config/load.ts +++ b/packages/backend/src/config/load.ts @@ -41,6 +41,7 @@ export default function load() { config.url = url.origin; config.port = config.port || parseInt(process.env.PORT || "", 10); + config.bind = config.bind || process.env.BIND; mixin.version = meta.version; mixin.host = url.host; diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts index 7789c26e07..7ead804a6f 100644 --- a/packages/backend/src/config/types.ts +++ b/packages/backend/src/config/types.ts @@ -6,6 +6,7 @@ export type Source = { feedback_url?: string; url: string; port: number; + bind?: string; disableHsts?: boolean; db: { host: string; diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index efff6dd236..6c205933d7 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -221,7 +221,10 @@ export const startServer = () => { initializeStreamingServer(server); - server.listen(config.port); + server.listen({ + port: config.port, + host: config.bind + }); return server; }; @@ -257,6 +260,8 @@ export default () => } }); - // @ts-ignore - server.listen(config.port, resolve); + server.listen({ + port: config.port, + host: config.bind + }, () => resolve(undefined)); });