enhance(backend): add unix socket support (#11275)

* unix socket support

* add changelog

* lint

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
dogcraft 2023-07-17 13:12:02 +08:00 committed by GitHub
parent 4f22176b8f
commit 5dab918999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 3 deletions

View File

@ -30,6 +30,10 @@ url: https://example.tld/
# The port that your Misskey server should listen on. # The port that your Misskey server should listen on.
port: 3000 port: 3000
# You can also use UNIX domain socket.
# socket: /path/to/misskey.sock
# chmodSocket: '777'
# ┌──────────────────────────┐ # ┌──────────────────────────┐
#───┘ PostgreSQL configuration └──────────────────────────────── #───┘ PostgreSQL configuration └────────────────────────────────

View File

@ -61,6 +61,7 @@
- Fix: Remove Meilisearch index when notes are deleted - Fix: Remove Meilisearch index when notes are deleted
- Fix: 非英語環境でのPostgreSQLのエラーハンドリングを修正 - Fix: 非英語環境でのPostgreSQLのエラーハンドリングを修正
- Fix: インスタンスのアイコンがbase64の場合の挙動を修正 - Fix: インスタンスのアイコンがbase64の場合の挙動を修正
- Add unix socket support
## 13.13.2 ## 13.13.2

View File

@ -78,7 +78,7 @@ export async function masterMain() {
await spawnWorkers(config.clusterLimit); 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 { function showEnvironment(): void {

View File

@ -14,7 +14,9 @@ export type Source = {
repository_url?: string; repository_url?: string;
feedback_url?: string; feedback_url?: string;
url: string; url: string;
port: number; port?: number;
socket?: string;
chmodSocket?: string;
disableHsts?: boolean; disableHsts?: boolean;
db: { db: {
host: string; host: string;

View File

@ -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(); await fastify.ready();
} }