增加运行指定命令接口

This commit is contained in:
whyour
2023-05-01 14:28:58 +08:00
parent df1addc1ff
commit aab6bbeb15
7 changed files with 124 additions and 25 deletions
+9 -1
View File
@@ -5,11 +5,12 @@ import * as fs from 'fs';
import { AuthDataType, AuthInfo, AuthModel, LoginStatus } from '../data/auth';
import { NotificationInfo } from '../data/notify';
import NotificationService from './notify';
import ScheduleService from './schedule';
import ScheduleService, { TaskCallbacks } from './schedule';
import { spawn } from 'child_process';
import SockService from './sock';
import got from 'got';
import { parseContentVersion, parseVersion } from '../config/util';
import { TASK_COMMAND } from '../config/const';
@Service()
export default class SystemService {
@@ -170,4 +171,11 @@ export default class SystemService {
return { code: 400, message: '通知发送失败,请检查系统设置/通知配置' };
}
}
public async run({ command }: { command: string }, callback: TaskCallbacks) {
if (!command.startsWith(TASK_COMMAND)) {
command = `${TASK_COMMAND} ${command}`;
}
this.scheduleService.runTask(`real_time=true ${command}`, callback);
}
}