2023-07-27 07:31:52 +02:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-01-23 12:07:48 +01:00
|
|
|
import { NestFactory } from '@nestjs/core';
|
|
|
|
import { ChartManagementService } from '@/core/chart/ChartManagementService.js';
|
|
|
|
import { QueueProcessorService } from '@/queue/QueueProcessorService.js';
|
|
|
|
import { NestLogger } from '@/NestLogger.js';
|
|
|
|
import { QueueProcessorModule } from '@/queue/QueueProcessorModule.js';
|
|
|
|
import { JanitorService } from '@/daemons/JanitorService.js';
|
|
|
|
import { QueueStatsService } from '@/daemons/QueueStatsService.js';
|
|
|
|
import { ServerStatsService } from '@/daemons/ServerStatsService.js';
|
|
|
|
import { ServerService } from '@/server/ServerService.js';
|
|
|
|
import { MainModule } from '@/MainModule.js';
|
|
|
|
|
|
|
|
export async function server() {
|
|
|
|
const app = await NestFactory.createApplicationContext(MainModule, {
|
|
|
|
logger: new NestLogger(),
|
|
|
|
});
|
|
|
|
app.enableShutdownHooks();
|
|
|
|
|
|
|
|
const serverService = app.get(ServerService);
|
2023-03-03 03:13:12 +01:00
|
|
|
await serverService.launch();
|
2023-01-23 12:07:48 +01:00
|
|
|
|
2023-05-10 08:30:36 +02:00
|
|
|
if (process.env.NODE_ENV !== 'test') {
|
|
|
|
app.get(ChartManagementService).start();
|
|
|
|
app.get(JanitorService).start();
|
|
|
|
app.get(QueueStatsService).start();
|
|
|
|
app.get(ServerStatsService).start();
|
|
|
|
}
|
2023-03-03 03:13:12 +01:00
|
|
|
|
|
|
|
return app;
|
2023-01-23 12:07:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function jobQueue() {
|
|
|
|
const jobQueue = await NestFactory.createApplicationContext(QueueProcessorModule, {
|
|
|
|
logger: new NestLogger(),
|
|
|
|
});
|
|
|
|
jobQueue.enableShutdownHooks();
|
|
|
|
|
|
|
|
jobQueue.get(QueueProcessorService).start();
|
|
|
|
jobQueue.get(ChartManagementService).start();
|
2023-05-09 01:32:25 +02:00
|
|
|
|
|
|
|
return jobQueue;
|
2023-01-23 12:07:48 +01:00
|
|
|
}
|