mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-12-05 10:18:38 +09:00
fix(backend): ServerStatsService start within running app
This commit is contained in:
parent
7097d553e4
commit
a4d2c54bf2
@ -344,6 +344,7 @@ import * as ep___fetchRss from './endpoints/fetch-rss.js';
|
||||
import * as ep___retention from './endpoints/retention.js';
|
||||
import { GetterService } from './GetterService.js';
|
||||
import { ApiLoggerService } from './ApiLoggerService.js';
|
||||
import { ServerStatsService } from '@/daemons/ServerStatsService.js';
|
||||
import type { Provider } from '@nestjs/common';
|
||||
|
||||
const $admin_meta: Provider = { provide: 'ep:admin/meta', useClass: ep___admin_meta.default };
|
||||
@ -695,6 +696,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention
|
||||
providers: [
|
||||
GetterService,
|
||||
ApiLoggerService,
|
||||
ServerStatsService,
|
||||
$admin_meta,
|
||||
$admin_abuseUserReports,
|
||||
$admin_accounts_create,
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import { DataSource } from 'typeorm';
|
||||
import type { Meta } from '@/models/entities/Meta.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import { ServerStatsService } from '@/daemons/ServerStatsService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
@ -109,6 +111,8 @@ export const paramDef = {
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
constructor(
|
||||
private moduleRef: ModuleRef,
|
||||
|
||||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@ -424,6 +428,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
|
||||
await this.metaService.update(set);
|
||||
this.moderationLogService.insertModerationLog(me, 'updateMeta');
|
||||
|
||||
if (set.enableServerMachineStats === true) {
|
||||
const serverStatsService: ServerStatsService = await this.moduleRef.resolve(ServerStatsService);
|
||||
await serverStatsService.start();
|
||||
} else {
|
||||
const serverStatsService: ServerStatsService = await this.moduleRef.resolve(ServerStatsService);
|
||||
serverStatsService.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user