Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): サーバーを始動する前に他のサービスが始動するように #15103

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
- Fix: ユーザーのプロフィール画面をアドレス入力などで直接表示した際に概要タブの描画に失敗する問題の修正( #15032 )
- Fix: 起動前の疎通チェックが機能しなくなっていた問題を修正
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/737)

- Fix: チャートエンジン・キュープロセッサが起動する前にサーバーがリクエストを受け付ける可能性がある問題を修正
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/788)

## 2024.11.0

Expand Down
17 changes: 9 additions & 8 deletions packages/backend/src/boot/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ export async function server() {
logger: new NestLogger(),
});

const serverService = app.get(ServerService);
await serverService.launch();

if (process.env.NODE_ENV !== 'test') {
app.get(ChartManagementService).start();
app.get(QueueStatsService).start();
app.get(ServerStatsService).start();
await app.get(ChartManagementService).start();
await app.get(QueueStatsService).start();
await app.get(ServerStatsService).start();
}

// Start server last so the other services can register hooks first
const serverService = app.get(ServerService);
await serverService.launch();

return app;
}

Expand All @@ -35,8 +36,8 @@ export async function jobQueue() {
logger: new NestLogger(),
});

jobQueue.get(QueueProcessorService).start();
jobQueue.get(ChartManagementService).start();
await jobQueue.get(QueueProcessorService).start();
await jobQueue.get(ChartManagementService).start();

return jobQueue;
}
4 changes: 2 additions & 2 deletions packages/backend/src/daemons/QueueStatsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class QueueStatsService implements OnApplicationShutdown {
* Report queue stats regularly
*/
@bindThis
public start(): void {
public async start(): Promise<void> {
const log = [] as any[];

ev.on('requestQueueStatsLog', x => {
Expand Down Expand Up @@ -82,7 +82,7 @@ export class QueueStatsService implements OnApplicationShutdown {
activeInboxJobs = 0;
};

tick();
await tick();

this.intervalId = setInterval(tick, interval);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/daemons/ServerStatsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class ServerStatsService implements OnApplicationShutdown {
if (log.length > 200) log.pop();
};

tick();
await tick();

this.intervalId = setInterval(tick, interval);
}
Expand Down
Loading