From e5360536f391b35019c9f2880448b93ccd96eab7 Mon Sep 17 00:00:00 2001 From: Mizunashi Mana Date: Sun, 16 Jul 2023 20:13:24 +0900 Subject: [PATCH 1/5] feat: Add bind address option --- .config/example.yml | 4 ++++ chart/templates/_helpers.tpl | 4 ++++ packages/backend/src/config/load.ts | 1 + packages/backend/src/config/types.ts | 1 + packages/backend/src/server/index.ts | 4 ++-- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index f73f4f1d7..6c4030eea 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -29,6 +29,10 @@ url: https://example.com/ # The port that your Calckey server should listen on. port: 3000 +# The bind host your Calckey server should listen on. +# If unspecified, the wildcard address will be using. +#bind: 127.0.0.1 + # ┌──────────────────────────┐ #───┘ PostgreSQL configuration └──────────────────────────────── diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index 81009ed01..d3d8561b7 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -113,6 +113,10 @@ url: "https://{{ .Values.calckey.domain }}/" # The port that your Misskey server should listen on. port: 3000 +# The bind host your Calckey server should listen on. +# If unspecified, the wildcard address will be using. +#bind: 127.0.0.1 + # ┌──────────────────────────┐ #───┘ PostgreSQL configuration └──────────────────────────────── diff --git a/packages/backend/src/config/load.ts b/packages/backend/src/config/load.ts index fa9878955..f6dfba927 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 7789c26e0..7ead804a6 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 efff6dd23..3e2aa87b0 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -221,7 +221,7 @@ export const startServer = () => { initializeStreamingServer(server); - server.listen(config.port); + server.listen(config.port, config.bind); return server; }; @@ -258,5 +258,5 @@ export default () => }); // @ts-ignore - server.listen(config.port, resolve); + server.listen(config.port, config.bind, resolve); }); From b9db50de081234964bd2fddc88d6f2801ca3c58f Mon Sep 17 00:00:00 2001 From: Mizunashi Mana Date: Sun, 16 Jul 2023 20:13:49 +0900 Subject: [PATCH 2/5] fix: Add error message on initialization failed --- packages/backend/src/boot/master.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index bee8c8b0c..9322e819a 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -77,7 +77,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); } From d5db0360a7ab7a4a7d8a1a386a37f3eb9157a3e5 Mon Sep 17 00:00:00 2001 From: Mizunashi Mana Date: Mon, 17 Jul 2023 09:17:47 +0900 Subject: [PATCH 3/5] fix: fix typo --- .config/example.yml | 2 +- chart/templates/_helpers.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index 6c4030eea..96e05ea51 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -30,7 +30,7 @@ url: https://example.com/ port: 3000 # The bind host your Calckey server should listen on. -# If unspecified, the wildcard address will be using. +# If unspecified, the wildcard address will be used. #bind: 127.0.0.1 # ┌──────────────────────────┐ diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index d3d8561b7..b5ebcb68b 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -114,7 +114,7 @@ url: "https://{{ .Values.calckey.domain }}/" port: 3000 # The bind host your Calckey server should listen on. -# If unspecified, the wildcard address will be using. +# If unspecified, the wildcard address will be used. #bind: 127.0.0.1 # ┌──────────────────────────┐ From b7c72b902dc6f1dbe11e174e1ba01a7872427de4 Mon Sep 17 00:00:00 2001 From: Mizunashi Mana Date: Mon, 17 Jul 2023 09:44:48 +0900 Subject: [PATCH 4/5] fix: Branch by bind address --- packages/backend/src/server/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index 3e2aa87b0..6c205933d 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, config.bind); + server.listen({ + port: config.port, + host: config.bind + }); return server; }; @@ -257,6 +260,8 @@ export default () => } }); - // @ts-ignore - server.listen(config.port, config.bind, resolve); + server.listen({ + port: config.port, + host: config.bind + }, () => resolve(undefined)); }); From f079e8b9edff512d759931e7f7dc2d0e9af7e2ec Mon Sep 17 00:00:00 2001 From: Mizunashi Mana Date: Mon, 17 Jul 2023 10:55:24 +0900 Subject: [PATCH 5/5] fix: Revert k8s template updates --- chart/templates/_helpers.tpl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index b5ebcb68b..81009ed01 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -113,10 +113,6 @@ url: "https://{{ .Values.calckey.domain }}/" # The port that your Misskey 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 └────────────────────────────────