Skip to content

Commit

Permalink
enhance(backend): add unix socket support (misskey-dev#11275)
Browse files Browse the repository at this point in the history
* unix socket support

* add changelog

* lint

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
  • Loading branch information
2 people authored and slofp committed Jul 21, 2023
1 parent 2d8d3bc commit c322698
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .config/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 └────────────────────────────────

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
- Fix: Remove Meilisearch index when notes are deleted
- Fix: 非英語環境でのPostgreSQLのエラーハンドリングを修正
- Fix: インスタンスのアイコンがbase64の場合の挙動を修正
- Add unix socket support

## 13.13.2

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/boot/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 12 additions & 1 deletion packages/backend/src/server/ServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit c322698

Please sign in to comment.