@whyour/qinglong 2.21.0-5 → 2.21.0-6
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
|
@@ -525,14 +525,6 @@ let CronService = class CronService {
|
|
|
525
525
|
const logPath = `${uniqPath}/${logTime}.log`;
|
|
526
526
|
const absolutePath = path_1.default.resolve(config_1.default.logPath, `${logPath}`);
|
|
527
527
|
const cp = (0, cross_spawn_1.spawn)(`real_log_path=${logPath} no_delay=true ${this.makeCommand(cron, true)}`, { shell: '/bin/bash' });
|
|
528
|
-
const startedAt = (0, dayjs_1.default)().unix();
|
|
529
|
-
const instance = await runningInstance_1.RunningInstanceModel.create({
|
|
530
|
-
cron_id: id,
|
|
531
|
-
pid: cp.pid,
|
|
532
|
-
log_path: logPath,
|
|
533
|
-
started_at: startedAt,
|
|
534
|
-
status: runningInstance_1.InstanceStatus.running,
|
|
535
|
-
});
|
|
536
528
|
await cron_1.CrontabModel.update({ status: cron_1.CrontabStatus.running, pid: cp.pid, log_path: logPath }, { where: { id } });
|
|
537
529
|
cp.stdout.on('data', async (data) => {
|
|
538
530
|
await logStreamManager_1.logStreamManager.write(absolutePath, data.toString());
|
|
@@ -548,19 +540,6 @@ let CronService = class CronService {
|
|
|
548
540
|
cp.on('exit', async (code) => {
|
|
549
541
|
this.logger.info('[panel][执行任务结束] 参数: %s, 退出码: %j', JSON.stringify(params), code);
|
|
550
542
|
await logStreamManager_1.logStreamManager.closeStream(absolutePath);
|
|
551
|
-
const finishedAt = (0, dayjs_1.default)().unix();
|
|
552
|
-
await runningInstance_1.RunningInstanceModel.update({
|
|
553
|
-
finished_at: finishedAt,
|
|
554
|
-
status: code === 0 ? runningInstance_1.InstanceStatus.finished : runningInstance_1.InstanceStatus.error,
|
|
555
|
-
exit_code: code !== null && code !== void 0 ? code : undefined,
|
|
556
|
-
}, { where: { id: instance.id } });
|
|
557
|
-
// Only set cron to idle if no other running instances exist
|
|
558
|
-
const otherRunning = await runningInstance_1.RunningInstanceModel.count({
|
|
559
|
-
where: { cron_id: id, status: runningInstance_1.InstanceStatus.running },
|
|
560
|
-
});
|
|
561
|
-
if (otherRunning === 0) {
|
|
562
|
-
await cron_1.CrontabModel.update({ status: cron_1.CrontabStatus.idle, pid: undefined }, { where: { id } });
|
|
563
|
-
}
|
|
564
543
|
resolve(Object.assign(Object.assign({}, params), { pid: cp.pid, code }));
|
|
565
544
|
});
|
|
566
545
|
});
|