mirror of
https://github.com/whyour/qinglong.git
synced 2026-02-12 22:16:42 +08:00
Fix: Only pass log_name to shell when it has a value
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
parent
374393b596
commit
fbad538db2
|
|
@ -509,11 +509,7 @@ export default class CronService {
|
||||||
const uniqPath =
|
const uniqPath =
|
||||||
log_name === '/dev/null'
|
log_name === '/dev/null'
|
||||||
? await getUniqPath(command, `${id}`)
|
? await getUniqPath(command, `${id}`)
|
||||||
: log_name || (await getUniqPath(command, `${id}`));
|
: log_name;
|
||||||
|
|
||||||
// Update cron.log_name with the calculated uniqPath to avoid passing null to shell
|
|
||||||
cron.log_name = uniqPath;
|
|
||||||
|
|
||||||
const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS');
|
const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS');
|
||||||
const logDirPath = path.resolve(config.logPath, `${uniqPath}`);
|
const logDirPath = path.resolve(config.logPath, `${uniqPath}`);
|
||||||
await fs.mkdir(logDirPath, { recursive: true });
|
await fs.mkdir(logDirPath, { recursive: true });
|
||||||
|
|
@ -645,7 +641,12 @@ 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)} `;
|
||||||
|
// Only include log_name if it has a value, shell will handle empty case automatically
|
||||||
|
if (tab.log_name) {
|
||||||
|
commandVariable += `log_name=${tab.log_name} `;
|
||||||
|
}
|
||||||
|
commandVariable += `no_tee=true ID=${tab.id} `;
|
||||||
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