2024-10-26 18:01:06 +08:00
|
|
|
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy } from '@certd/pipeline';
|
2025-07-22 11:51:27 +08:00
|
|
|
import { httpsServer } from '../../modules/auto/https/server.js';
|
2024-09-07 11:55:23 +08:00
|
|
|
|
|
|
|
|
@IsTaskPlugin({
|
|
|
|
|
name: 'RestartCertd',
|
2024-10-26 18:01:06 +08:00
|
|
|
title: '重启 Certd',
|
2024-09-19 17:38:51 +08:00
|
|
|
icon: 'mdi:restart',
|
2024-10-26 18:01:06 +08:00
|
|
|
desc: '【仅管理员可用】 重启 certd的https服务,用于更新 Certd 的 ssl 证书',
|
2025-07-22 12:22:54 +08:00
|
|
|
group: pluginGroups.admin.key,
|
2025-07-22 11:51:27 +08:00
|
|
|
onlyAdmin:true,
|
2024-09-07 11:55:23 +08:00
|
|
|
default: {
|
|
|
|
|
strategy: {
|
|
|
|
|
runStrategy: RunStrategy.SkipWhenSucceed,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
export class RestartCertdPlugin extends AbstractTaskPlugin {
|
|
|
|
|
async onInstance() {}
|
|
|
|
|
async execute(): Promise<void> {
|
2024-09-29 01:14:21 +08:00
|
|
|
if (!this.isAdmin()) {
|
|
|
|
|
throw new Error('只有管理员才能运行此任务');
|
|
|
|
|
}
|
2024-10-26 18:01:06 +08:00
|
|
|
this.logger.info('Certd https server 将在 3 秒后重启');
|
|
|
|
|
await this.ctx.utils.sleep(3000);
|
|
|
|
|
await httpsServer.restart();
|
2024-09-07 11:55:23 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
new RestartCertdPlugin();
|