mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-24 07:16:08 +08:00
修复cron日志获取逻辑
This commit is contained in:
parent
7105952670
commit
2a7d298f05
|
@ -124,7 +124,7 @@ export default class CronService {
|
||||||
fs.writeFileSync(logFile, `开始执行...\n\n${new Date().toString()}\n`);
|
fs.writeFileSync(logFile, `开始执行...\n\n${new Date().toString()}\n`);
|
||||||
|
|
||||||
let cmdStr = res.command;
|
let cmdStr = res.command;
|
||||||
if (res.command.startsWith('js')) {
|
if (res.command.startsWith('js') && !res.command.endsWith('now')) {
|
||||||
cmdStr = `${res.command} now`;
|
cmdStr = `${res.command} now`;
|
||||||
} else if (/&& (.*) >>/.test(res.command)) {
|
} else if (/&& (.*) >>/.test(res.command)) {
|
||||||
cmdStr = res.command.match(/&& (.*) >>/)[1];
|
cmdStr = res.command.match(/&& (.*) >>/)[1];
|
||||||
|
|
|
@ -19,7 +19,6 @@ const CronLogModal = ({
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [value, setValue] = useState<string>('启动中...');
|
const [value, setValue] = useState<string>('启动中...');
|
||||||
const [logTimer, setLogTimer] = useState<any>();
|
|
||||||
const [loading, setLoading] = useState<any>(true);
|
const [loading, setLoading] = useState<any>(true);
|
||||||
|
|
||||||
const getCronLog = (isFirst?: boolean) => {
|
const getCronLog = (isFirst?: boolean) => {
|
||||||
|
@ -31,20 +30,10 @@ const CronLogModal = ({
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
const log = data.data as string;
|
const log = data.data as string;
|
||||||
setValue(log || '暂无日志');
|
setValue(log || '暂无日志');
|
||||||
if (log.includes('执行结束')) {
|
if (log && log.includes('执行结束')) {
|
||||||
if (logTimer) {
|
setTimeout(() => {
|
||||||
clearInterval(logTimer);
|
|
||||||
}
|
|
||||||
} else if (isFirst) {
|
|
||||||
const timer = setInterval(() => {
|
|
||||||
getCronLog();
|
getCronLog();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
setLogTimer(timer);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
if (logTimer) {
|
|
||||||
clearInterval(logTimer);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
@ -55,7 +44,6 @@ const CronLogModal = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
clearInterval(logTimer);
|
|
||||||
handleCancel();
|
handleCancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +62,7 @@ const CronLogModal = ({
|
||||||
onCancel={() => cancel()}
|
onCancel={() => cancel()}
|
||||||
>
|
>
|
||||||
<pre style={{ whiteSpace: 'pre-wrap', wordWrap: 'break-word' }}>
|
<pre style={{ whiteSpace: 'pre-wrap', wordWrap: 'break-word' }}>
|
||||||
{value}
|
{!loading && value}
|
||||||
</pre>
|
</pre>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user