@whyour/qinglong 0.19.1 → 0.19.3

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
- "version": "0.19.1",
3
+ "version": "0.19.3",
4
4
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
5
5
  "repository": {
6
6
  "type": "git",
@@ -101,7 +101,7 @@
101
101
  "node-schedule": "^2.1.0",
102
102
  "nodemailer": "^6.7.2",
103
103
  "p-queue-cjs": "7.3.4",
104
- "protobufjs": "^7.2.3",
104
+ "protobufjs": "^7.3.0",
105
105
  "pstree.remy": "^1.1.8",
106
106
  "reflect-metadata": "^0.1.13",
107
107
  "sequelize": "^6.25.5",
@@ -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} real_time=true no_delay=true ${this.makeCommand(cron)}`, { shell: '/bin/bash' });
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,15 +95,15 @@ let SubscriptionService = class SubscriptionService {
95
95
  throw error;
96
96
  }
97
97
  }
98
- async handleTask(doc, needCreate = true, runImmediately = false) {
99
- const { url } = (0, subscription_2.formatUrl)(doc);
100
- doc.command = (0, subscription_2.formatCommand)(doc, url);
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 &&
104
104
  (await this.scheduleService.createCronTask(doc, this.taskCallbacks(doc), runImmediately));
105
105
  }
106
- else {
106
+ else if (doc.interval_schedule) {
107
107
  this.scheduleService.cancelIntervalTask(doc);
108
108
  const { type, value } = doc.interval_schedule;
109
109
  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
- return doc && doc.get({ plain: true });
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 } });