mirror of
https://github.com/whyour/qinglong.git
synced 2025-11-28 05:05:37 +08:00
Fix null log_name issue by omitting it from shell command when not set (#2849)
* Initial plan * Fix null log_name handling in runSingle method Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Update cron.log_name before makeCommand to avoid passing null to shell Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Fix: Only pass log_name to shell when it has a value Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Fix uniqPath calculation in runSingle for null log_name Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Improve comment clarity in makeCommand Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Refactor: Move no_tee and ID to initial commandVariable declaration Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Refactor: Simplify uniqPath ternary expression Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
parent
177cd3de81
commit
6a3dd4f83c
|
|
@ -507,7 +507,7 @@ export default class CronService {
|
||||||
let { id, command, log_name } = cron;
|
let { id, command, log_name } = cron;
|
||||||
|
|
||||||
const uniqPath =
|
const uniqPath =
|
||||||
log_name === '/dev/null'
|
log_name === '/dev/null' || !log_name
|
||||||
? await getUniqPath(command, `${id}`)
|
? await getUniqPath(command, `${id}`)
|
||||||
: log_name;
|
: log_name;
|
||||||
const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS');
|
const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS');
|
||||||
|
|
@ -641,7 +641,11 @@ export default class CronService {
|
||||||
if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) {
|
if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) {
|
||||||
command = `${TASK_PREFIX}${tab.command}`;
|
command = `${TASK_PREFIX}${tab.command}`;
|
||||||
}
|
}
|
||||||
let commandVariable = `real_time=${Boolean(realTime)} log_name=${tab.log_name} no_tee=true ID=${tab.id} `;
|
let commandVariable = `real_time=${Boolean(realTime)} no_tee=true ID=${tab.id} `;
|
||||||
|
// Only include log_name if it has a truthy value to avoid passing null/undefined to shell
|
||||||
|
if (tab.log_name) {
|
||||||
|
commandVariable += `log_name=${tab.log_name} `;
|
||||||
|
}
|
||||||
if (tab.task_before) {
|
if (tab.task_before) {
|
||||||
commandVariable += `task_before='${tab.task_before
|
commandVariable += `task_before='${tab.task_before
|
||||||
.replace(/'/g, "'\\''")
|
.replace(/'/g, "'\\''")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user