perf: 支持同时监听https端口,7002

This commit is contained in:
xiaojunnuo
2024-10-26 16:36:57 +08:00
parent 4b09a0a27f
commit d5a17f9e6a
7 changed files with 132 additions and 3 deletions
@@ -1,8 +1,10 @@
import { Autoload, Init, Inject, Scope, ScopeEnum } from '@midwayjs/core';
import { App, Autoload, Config, Init, Inject, Scope, ScopeEnum } from '@midwayjs/core';
import { getPlusInfo, isPlus, logger } from '@certd/pipeline';
import { SysInstallInfo, SysSettingsService } from '@certd/lib-server';
import { getVersion } from '../../utils/version.js';
import dayjs from 'dayjs';
import { Application } from '@midwayjs/koa';
import { HttpsServerOptions, startHttpsServer } from './https/server.js';
@Autoload()
@Scope(ScopeEnum.Singleton)
@@ -10,8 +12,17 @@ export class AutoZPrint {
@Inject()
sysSettingsService: SysSettingsService;
@App()
app: Application;
@Config('https')
httpsConfig: HttpsServerOptions;
@Init()
async init() {
//监听https
this.startHttpsServer();
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
logger.info('=========================================');
logger.info('当前站点ID:', installInfo.siteId);
@@ -24,4 +35,15 @@ export class AutoZPrint {
logger.info('Certd已启动');
logger.info('=========================================');
}
async startHttpsServer() {
if (!this.httpsConfig.enabled) {
logger.info('Https server is not enabled');
return;
}
await startHttpsServer({
...this.httpsConfig,
app: this.app,
});
}
}