diff --git a/.config/example.yml b/.config/example.yml index c8735bf699..fcf22debce 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -30,6 +30,10 @@ url: https://example.tld/ # The port that your Misskey server should listen on. port: 3000 +# You can also use UNIX domain socket. +# socket: /path/to/misskey.sock +# chmodSocket: '777' + # ┌──────────────────────────┐ #───┘ PostgreSQL configuration └──────────────────────────────── diff --git a/CHANGELOG.md b/CHANGELOG.md index 85e459b950..480dc2c9a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ - Fix: Remove Meilisearch index when notes are deleted - Fix: 非英語環境でのPostgreSQLのエラーハンドリングを修正 - Fix: インスタンスのアイコンがbase64の場合の挙動を修正 +- Add unix socket support ## 13.13.2 diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index b04234fd1f..c253f697f7 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -78,7 +78,7 @@ export async function masterMain() { await spawnWorkers(config.clusterLimit); } - bootLogger.succ(`Now listening on port ${config.port} on ${config.url}`, null, true); + bootLogger.succ(config.socket ? `Now listening on socket ${config.socket} on ${config.url}` : `Now listening on port ${config.port} on ${config.url}`, null, true); } function showEnvironment(): void { diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 23ed6e59bc..8c312256da 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -14,7 +14,9 @@ export type Source = { repository_url?: string; feedback_url?: string; url: string; - port: number; + port?: number; + socket?: string; + chmodSocket?: string; disableHsts?: boolean; db: { host: string; diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index 1bae71617b..051920958e 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -224,7 +224,18 @@ export class ServerService implements OnApplicationShutdown { } }); - fastify.listen({ port: this.config.port, host: '0.0.0.0' }); + if (this.config.socket) { + if (fs.existsSync(this.config.socket)) { + fs.unlinkSync(this.config.socket); + } + fastify.listen({ path: this.config.socket }, (err, address) => { + if (this.config.chmodSocket) { + fs.chmodSync(this.config.socket!, this.config.chmodSocket); + } + }); + } else { + fastify.listen({ port: this.config.port, host: '0.0.0.0' }); + } await fastify.ready(); }