修改内置token获取方式

This commit is contained in:
whyour
2022-08-11 13:13:37 +08:00
parent 53414e5d70
commit a7117e4442
4 changed files with 22 additions and 8 deletions
+19 -1
View File
@@ -3,12 +3,30 @@ import _ from 'lodash';
import SystemService from '../services/system';
import ScheduleService from '../services/schedule';
import SubscriptionService from '../services/subscription';
import config from '../config';
import { fileExist } from '../config/util';
export default async () => {
const systemService = Container.get(SystemService);
const scheduleService = Container.get(ScheduleService);
const subscriptionService = Container.get(SubscriptionService);
// 生成内置token
let tokenCommand = `ts-node-transpile-only ${config.rootPath}/back/token.ts`;
const tokenFile = `${config.rootPath}/static/build/token.js`;
if (await fileExist(tokenFile)) {
tokenCommand = `node ${tokenFile}`;
}
const cron = {
id: 'token',
name: '生成token',
command: tokenCommand,
};
scheduleService.createIntervalTask(cron as any, {
days: 28,
runImmediately: true,
});
// 运行删除日志任务
const data = await systemService.getLogRemoveFrequency();
if (data && data.info && data.info.frequency) {
@@ -17,7 +35,7 @@ export default async () => {
name: '删除日志',
command: `ql rmlog ${data.info.frequency}`,
};
await scheduleService.createIntervalTask(cron, {
scheduleService.createIntervalTask(cron, {
days: data.info.frequency,
runImmediately: true,
});
+1 -1
View File
@@ -169,7 +169,7 @@ export default class ScheduleService {
);
const job = new LongIntervalJob(
{ ...schedule, runImmediately: false },
{ runImmediately: false, ...schedule },
task,
_id,
);