mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
修复定时任务 real_time 参数,升级 protobufjs
This commit is contained in:
@@ -435,7 +435,10 @@ export default class CronService {
|
||||
const logPath = `${uniqPath}/${logTime}.log`;
|
||||
const absolutePath = path.resolve(config.logPath, `${logPath}`);
|
||||
const cp = spawn(
|
||||
`real_log_path=${logPath} real_time=true no_delay=true ${this.makeCommand(cron)}`,
|
||||
`real_log_path=${logPath} no_delay=true ${this.makeCommand(
|
||||
cron,
|
||||
true
|
||||
)}`,
|
||||
{ shell: '/bin/bash' },
|
||||
);
|
||||
|
||||
@@ -526,12 +529,14 @@ export default class CronService {
|
||||
}
|
||||
}
|
||||
|
||||
private makeCommand(tab: Crontab) {
|
||||
private makeCommand(tab: Crontab, realTime?: boolean) {
|
||||
let command = tab.command.trim();
|
||||
if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) {
|
||||
command = `${TASK_PREFIX}${tab.command}`;
|
||||
}
|
||||
let commandVariable = `no_tee=true ID=${tab.id} `;
|
||||
let commandVariable = `real_time=${Boolean(realTime)} no_tee=true ID=${
|
||||
tab.id
|
||||
} `;
|
||||
if (tab.task_before) {
|
||||
commandVariable += `task_before='${tab.task_before
|
||||
.replace(/'/g, "'\\''")
|
||||
|
||||
@@ -13,7 +13,7 @@ import taskLimit from '../shared/pLimit';
|
||||
import { spawn } from 'cross-spawn';
|
||||
|
||||
export interface ScheduleTaskType {
|
||||
id: number;
|
||||
id?: number;
|
||||
command: string;
|
||||
name?: string;
|
||||
schedule?: string;
|
||||
|
||||
@@ -91,9 +91,9 @@ export default class SubscriptionService {
|
||||
this.taskCallbacks(doc),
|
||||
runImmediately,
|
||||
));
|
||||
} else {
|
||||
} else if (doc.interval_schedule) {
|
||||
this.scheduleService.cancelIntervalTask(doc as any);
|
||||
const { type, value } = doc.interval_schedule as any;
|
||||
const { type, value } = doc.interval_schedule;
|
||||
needCreate &&
|
||||
(await this.scheduleService.createIntervalTask(
|
||||
doc as any,
|
||||
@@ -256,7 +256,7 @@ export default class SubscriptionService {
|
||||
);
|
||||
}
|
||||
|
||||
public async remove(ids: number[], query: any) {
|
||||
public async remove(ids: number[], query: { force?: boolean }) {
|
||||
const docs = await SubscriptionModel.findAll({ where: { id: ids } });
|
||||
for (const doc of docs) {
|
||||
await this.handleTask(doc, false);
|
||||
@@ -279,8 +279,11 @@ export default class SubscriptionService {
|
||||
public async getDb(
|
||||
query: FindOptions<Subscription>['where'],
|
||||
): Promise<Subscription> {
|
||||
const doc: any = await SubscriptionModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as Subscription);
|
||||
const doc = await SubscriptionModel.findOne({ where: { ...query } });
|
||||
if (!doc) {
|
||||
throw new Error(`${JSON.stringify(query)} not found`);
|
||||
}
|
||||
return doc.get({ plain: true });
|
||||
}
|
||||
|
||||
public async run(ids: number[]) {
|
||||
|
||||
Reference in New Issue
Block a user