mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复定时任务间隔较小,任务状态不准确
This commit is contained in:
parent
77a8e00b17
commit
eddc03e295
|
@ -458,13 +458,12 @@ export default (app: Router) => {
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const logger: Logger = Container.get('logger');
|
|
||||||
try {
|
try {
|
||||||
const cronService = Container.get(CronService);
|
const cronService = Container.get(CronService);
|
||||||
const data = await cronService.status({
|
const data = await cronService.status({
|
||||||
...req.body,
|
...req.body,
|
||||||
status: parseInt(req.body.status),
|
status: req.body.status ? parseInt(req.body.status) : undefined,
|
||||||
pid: parseInt(req.body.pid) || '',
|
pid: req.body.pid ? parseInt(req.body.pid) : undefined,
|
||||||
});
|
});
|
||||||
return res.send({ code: 200, data });
|
return res.send({ code: 200, data });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -14,6 +14,8 @@ import cronClient from '../schedule/client';
|
||||||
import taskLimit from '../shared/pLimit';
|
import taskLimit from '../shared/pLimit';
|
||||||
import { spawn } from 'cross-spawn';
|
import { spawn } from 'cross-spawn';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import pickBy from 'lodash/pickBy';
|
||||||
|
import omit from 'lodash/omit';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class CronService {
|
export default class CronService {
|
||||||
|
@ -89,7 +91,7 @@ export default class CronService {
|
||||||
last_running_time: number;
|
last_running_time: number;
|
||||||
last_execution_time: number;
|
last_execution_time: number;
|
||||||
}) {
|
}) {
|
||||||
const options: any = {
|
let options: any = {
|
||||||
status,
|
status,
|
||||||
pid,
|
pid,
|
||||||
log_path,
|
log_path,
|
||||||
|
@ -99,7 +101,13 @@ export default class CronService {
|
||||||
options.last_running_time = last_running_time;
|
options.last_running_time = last_running_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await CrontabModel.update({ ...options }, { where: { id: ids } });
|
for (const id of ids) {
|
||||||
|
const cron = await this.getDb({ id });
|
||||||
|
if (status === CrontabStatus.idle && log_path !== cron.log_path) {
|
||||||
|
options = omit(options, ['status', 'log_path', 'pid']);
|
||||||
|
}
|
||||||
|
await CrontabModel.update({ ...pickBy(options, (v) => v === 0 || !!v) }, { where: { id } });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async remove(ids: number[]) {
|
public async remove(ids: number[]) {
|
||||||
|
|
|
@ -460,7 +460,7 @@ handle_task_after() {
|
||||||
|
|
||||||
[[ "$diff_time" == 0 ]] && diff_time=1
|
[[ "$diff_time" == 0 ]] && diff_time=1
|
||||||
|
|
||||||
echo -e "\n\n## 执行结束... $end_time 耗时 $diff_time 秒 "
|
echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒 "
|
||||||
|
|
||||||
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-modal-body {
|
.ant-modal-body {
|
||||||
max-height: calc(90vh - 110px);
|
max-height: calc(80vh - 110px);
|
||||||
max-height: calc(90vh - var(--vh-offset, 110px));
|
max-height: calc(80vh - var(--vh-offset, 110px));
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +181,7 @@ body {
|
||||||
.react-codemirror2,
|
.react-codemirror2,
|
||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
import { PageLoading } from '@ant-design/pro-layout';
|
import { PageLoading } from '@ant-design/pro-layout';
|
||||||
import { logEnded } from '@/utils';
|
import { logEnded } from '@/utils';
|
||||||
import { CrontabStatus } from './type';
|
import { CrontabStatus } from './type';
|
||||||
|
import Ansi from 'ansi-to-react';
|
||||||
|
|
||||||
const { Countdown } = Statistic;
|
const { Countdown } = Statistic;
|
||||||
|
|
||||||
|
@ -148,7 +149,7 @@ const CronLogModal = ({
|
||||||
: {}
|
: {}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{value}
|
<Ansi>{value}</Ansi>
|
||||||
</pre>
|
</pre>
|
||||||
)}
|
)}
|
||||||
<div id="log-flag"></div>
|
<div id="log-flag"></div>
|
||||||
|
|
|
@ -16,6 +16,7 @@ import SettingModal from './setting';
|
||||||
import { useTheme } from '@/utils/hooks';
|
import { useTheme } from '@/utils/hooks';
|
||||||
import { getEditorMode, logEnded } from '@/utils';
|
import { getEditorMode, logEnded } from '@/utils';
|
||||||
import WebSocketManager from '@/utils/websocket';
|
import WebSocketManager from '@/utils/websocket';
|
||||||
|
import Ansi from 'ansi-to-react';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ const EditModal = ({
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLog(p=>`${p}${_message}`);
|
setLog((p) => `${p}${_message}`);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -246,7 +247,7 @@ const EditModal = ({
|
||||||
padding: '0 15px',
|
padding: '0 15px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{log}
|
<Ansi>{log}</Ansi>
|
||||||
</pre>
|
</pre>
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
<SaveModal
|
<SaveModal
|
||||||
|
|
|
@ -77,7 +77,7 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
content: <pre>{lastLog}</pre>,
|
content: <pre><Ansi>{lastLog}</Ansi></pre>,
|
||||||
okText: intl.get('下载更新'),
|
okText: intl.get('下载更新'),
|
||||||
cancelText: intl.get('以后再说'),
|
cancelText: intl.get('以后再说'),
|
||||||
onOk() {
|
onOk() {
|
||||||
|
@ -102,7 +102,7 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||||
okButtonProps: { disabled: true },
|
okButtonProps: { disabled: true },
|
||||||
title: intl.get('下载更新中...'),
|
title: intl.get('下载更新中...'),
|
||||||
centered: true,
|
centered: true,
|
||||||
content: <pre>{value}</pre>,
|
content: <pre><Ansi>{value}</Ansi></pre>,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { PageLoading } from '@ant-design/pro-layout';
|
import { PageLoading } from '@ant-design/pro-layout';
|
||||||
import { logEnded } from '@/utils';
|
import { logEnded } from '@/utils';
|
||||||
|
import Ansi from 'ansi-to-react';
|
||||||
|
|
||||||
const SubscriptionLogModal = ({
|
const SubscriptionLogModal = ({
|
||||||
subscription,
|
subscription,
|
||||||
|
@ -122,7 +123,7 @@ const SubscriptionLogModal = ({
|
||||||
: {}
|
: {}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{value}
|
<Ansi>{value}</Ansi>
|
||||||
</pre>
|
</pre>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user