mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +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`);
|
||||
|
||||
let cmdStr = res.command;
|
||||
if (res.command.startsWith('js')) {
|
||||
if (res.command.startsWith('js') && !res.command.endsWith('now')) {
|
||||
cmdStr = `${res.command} now`;
|
||||
} else if (/&& (.*) >>/.test(res.command)) {
|
||||
cmdStr = res.command.match(/&& (.*) >>/)[1];
|
||||
|
|
|
@ -19,7 +19,6 @@ const CronLogModal = ({
|
|||
handleCancel: () => void;
|
||||
}) => {
|
||||
const [value, setValue] = useState<string>('启动中...');
|
||||
const [logTimer, setLogTimer] = useState<any>();
|
||||
const [loading, setLoading] = useState<any>(true);
|
||||
|
||||
const getCronLog = (isFirst?: boolean) => {
|
||||
|
@ -31,20 +30,10 @@ const CronLogModal = ({
|
|||
.then((data: any) => {
|
||||
const log = data.data as string;
|
||||
setValue(log || '暂无日志');
|
||||
if (log.includes('执行结束')) {
|
||||
if (logTimer) {
|
||||
clearInterval(logTimer);
|
||||
}
|
||||
} else if (isFirst) {
|
||||
const timer = setInterval(() => {
|
||||
if (log && log.includes('执行结束')) {
|
||||
setTimeout(() => {
|
||||
getCronLog();
|
||||
}, 2000);
|
||||
setLogTimer(timer);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
if (logTimer) {
|
||||
clearInterval(logTimer);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
|
@ -55,7 +44,6 @@ const CronLogModal = ({
|
|||
};
|
||||
|
||||
const cancel = () => {
|
||||
clearInterval(logTimer);
|
||||
handleCancel();
|
||||
};
|
||||
|
||||
|
@ -74,7 +62,7 @@ const CronLogModal = ({
|
|||
onCancel={() => cancel()}
|
||||
>
|
||||
<pre style={{ whiteSpace: 'pre-wrap', wordWrap: 'break-word' }}>
|
||||
{value}
|
||||
{!loading && value}
|
||||
</pre>
|
||||
</Modal>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user