diff --git a/back/services/cron.ts b/back/services/cron.ts index 34b6a799..55aeb557 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -407,7 +407,7 @@ export default class CronService { } private async runSingle(cronId: number): Promise { - return taskLimit.runWithCronLimit(() => { + return taskLimit.manualRunWithCronLimit(() => { return new Promise(async (resolve: any) => { const cron = await this.getDb({ id: cronId }); const params = { @@ -434,9 +434,8 @@ export default class CronService { } const logPath = `${uniqPath}/${logTime}.log`; const absolutePath = path.resolve(config.logPath, `${logPath}`); - const cp = spawn( - `real_log_path=${logPath} no_delay=true ${this.makeCommand(cron)}`, + `real_log_path=${logPath} real_time=true no_delay=true ${this.makeCommand(cron)}`, { shell: '/bin/bash' }, ); @@ -444,11 +443,14 @@ export default class CronService { { status: CrontabStatus.running, pid: cp.pid, log_path: logPath }, { where: { id } }, ); + cp.stdout.on('data', async (data) => { + await fs.appendFile(absolutePath, data.toString()); + }); cp.stderr.on('data', async (data) => { - await fs.appendFile(`${absolutePath}`, `${data.toString()}`); + await fs.appendFile(absolutePath, data.toString()); }); cp.on('error', async (err) => { - await fs.appendFile(`${absolutePath}`, `${JSON.stringify(err)}`); + await fs.appendFile(absolutePath, JSON.stringify(err)); }); cp.on('exit', async (code) => { diff --git a/back/services/system.ts b/back/services/system.ts index c7eb5047..afc3e571 100644 --- a/back/services/system.ts +++ b/back/services/system.ts @@ -348,20 +348,13 @@ export default class SystemService { } } - public async run( - { command, logPath }: { command: string; logPath: string }, - callback: TaskCallbacks, - ) { + public async run({ command }: { command: string }, callback: TaskCallbacks) { if (!command.startsWith(TASK_COMMAND)) { command = `${TASK_COMMAND} ${command}`; } - this.scheduleService.runTask( - `real_log_path=${logPath} real_time=true ${command}`, - callback, - { - command, - }, - ); + this.scheduleService.runTask(`real_time=true ${command}`, callback, { + command, + }); } public async stop({ command, pid }: { command: string; pid: number }) { @@ -388,7 +381,9 @@ export default class SystemService { public async exportData(res: Response) { try { - await promiseExec(`cd ${config.rootPath} && tar -zcvf ${config.dataTgzFile} data/`); + await promiseExec( + `cd ${config.rootPath} && tar -zcvf ${config.dataTgzFile} data/`, + ); res.download(config.dataTgzFile); } catch (error: any) { return res.send({ code: 400, message: error.message }); diff --git a/back/shared/pLimit.ts b/back/shared/pLimit.ts index 82a52bb1..19d152d7 100644 --- a/back/shared/pLimit.ts +++ b/back/shared/pLimit.ts @@ -15,6 +15,9 @@ class TaskLimit { private cronLimit = new PQueue({ concurrency: Math.max(os.cpus().length, 4), }); + private manualCronoLimit = new PQueue({ + concurrency: Math.max(os.cpus().length, 4), + }); get cronLimitActiveCount() { return this.cronLimit.pending; @@ -71,6 +74,7 @@ class TaskLimit { public async setCustomLimit(limit?: number) { if (limit) { this.cronLimit.concurrency = limit; + this.manualCronoLimit.concurrency = limit; return; } await SystemModel.sync(); @@ -79,6 +83,7 @@ class TaskLimit { }); if (doc?.info?.cronConcurrency) { this.cronLimit.concurrency = doc.info.cronConcurrency; + this.manualCronoLimit.concurrency = doc.info.cronConcurrency; } } @@ -89,6 +94,13 @@ class TaskLimit { return this.cronLimit.add(fn, options); } + public async manualRunWithCronLimit( + fn: () => Promise, + options?: Partial, + ): Promise { + return this.manualCronoLimit.add(fn, options); + } + public runDependeny( dependency: Dependence, fn: IDependencyFn, diff --git a/src/pages/config/index.tsx b/src/pages/config/index.tsx index af82602b..69217bf4 100644 --- a/src/pages/config/index.tsx +++ b/src/pages/config/index.tsx @@ -136,6 +136,7 @@ const Config = () => { lineNumbersMinChars: 3, folding: false, glyphMargin: false, + accessibilitySupport: 'off' }} onMount={(editor) => { editorRef.current = editor; diff --git a/src/pages/crontab/detail.tsx b/src/pages/crontab/detail.tsx index 808ae8b2..a29d706a 100644 --- a/src/pages/crontab/detail.tsx +++ b/src/pages/crontab/detail.tsx @@ -110,6 +110,7 @@ const CronDetailModal = ({ minimap: { enabled: false }, lineNumbersMinChars: 3, glyphMargin: false, + accessibilitySupport: 'off' }} onMount={(editor, monaco) => { editorRef.current = editor; diff --git a/src/pages/script/editModal.tsx b/src/pages/script/editModal.tsx index c69e8f1f..c898e31b 100644 --- a/src/pages/script/editModal.tsx +++ b/src/pages/script/editModal.tsx @@ -242,6 +242,7 @@ const EditModal = ({ minimap: { enabled: false }, lineNumbersMinChars: 3, glyphMargin: false, + accessibilitySupport: 'off' }} onMount={(editor) => { editorRef.current = editor; diff --git a/src/pages/script/index.tsx b/src/pages/script/index.tsx index d12b5fe6..0d822efd 100644 --- a/src/pages/script/index.tsx +++ b/src/pages/script/index.tsx @@ -643,6 +643,7 @@ const Script = () => { fontSize: 12, lineNumbersMinChars: 3, glyphMargin: false, + accessibilitySupport: 'off' }} onMount={(editor) => { editorRef.current = editor;