@whyour/qinglong 0.19.1 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -370,7 +370,7 @@ let CronService = class CronService {
|
|
|
370
370
|
}
|
|
371
371
|
const logPath = `${uniqPath}/${logTime}.log`;
|
|
372
372
|
const absolutePath = path_1.default.resolve(config_1.default.logPath, `${logPath}`);
|
|
373
|
-
const cp = (0, cross_spawn_1.spawn)(`real_log_path=${logPath}
|
|
373
|
+
const cp = (0, cross_spawn_1.spawn)(`real_log_path=${logPath} no_delay=true ${this.makeCommand(cron, true)}`, { shell: '/bin/bash' });
|
|
374
374
|
await cron_1.CrontabModel.update({ status: cron_1.CrontabStatus.running, pid: cp.pid, log_path: logPath }, { where: { id } });
|
|
375
375
|
cp.stdout.on('data', async (data) => {
|
|
376
376
|
await promises_1.default.appendFile(absolutePath, data.toString());
|
|
@@ -440,12 +440,12 @@ let CronService = class CronService {
|
|
|
440
440
|
return [];
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
makeCommand(tab) {
|
|
443
|
+
makeCommand(tab, realTime) {
|
|
444
444
|
let command = tab.command.trim();
|
|
445
445
|
if (!command.startsWith(const_1.TASK_PREFIX) && !command.startsWith(const_1.QL_PREFIX)) {
|
|
446
446
|
command = `${const_1.TASK_PREFIX}${tab.command}`;
|
|
447
447
|
}
|
|
448
|
-
let commandVariable = `no_tee=true ID=${tab.id} `;
|
|
448
|
+
let commandVariable = `real_time=${Boolean(realTime)} no_tee=true ID=${tab.id} `;
|
|
449
449
|
if (tab.task_before) {
|
|
450
450
|
commandVariable += `task_before='${tab.task_before
|
|
451
451
|
.replace(/'/g, "'\\''")
|
|
@@ -95,9 +95,9 @@ let SubscriptionService = class SubscriptionService {
|
|
|
95
95
|
throw error;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
async handleTask(
|
|
99
|
-
const { url } = (0, subscription_2.formatUrl)(
|
|
100
|
-
doc
|
|
98
|
+
async handleTask(_doc, needCreate = true, runImmediately = false) {
|
|
99
|
+
const { url } = (0, subscription_2.formatUrl)(_doc);
|
|
100
|
+
const doc = Object.assign(Object.assign({}, _doc), { command: (0, subscription_2.formatCommand)(_doc, url) });
|
|
101
101
|
if (doc.schedule_type === 'crontab') {
|
|
102
102
|
this.scheduleService.cancelCronTask(doc);
|
|
103
103
|
needCreate &&
|
|
@@ -237,7 +237,10 @@ let SubscriptionService = class SubscriptionService {
|
|
|
237
237
|
}
|
|
238
238
|
async getDb(query) {
|
|
239
239
|
const doc = await subscription_1.SubscriptionModel.findOne({ where: Object.assign({}, query) });
|
|
240
|
-
|
|
240
|
+
if (!doc) {
|
|
241
|
+
throw new Error(`${JSON.stringify(query)} not found`);
|
|
242
|
+
}
|
|
243
|
+
return doc.get({ plain: true });
|
|
241
244
|
}
|
|
242
245
|
async run(ids) {
|
|
243
246
|
await subscription_1.SubscriptionModel.update({ status: subscription_1.SubscriptionStatus.queued }, { where: { id: ids } });
|