mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-25 00:16:06 +08:00
修复禁用任务后git_pull会重新添加
This commit is contained in:
parent
78ab74fe1b
commit
a0c5b33239
|
@ -82,7 +82,7 @@ export default class CronService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run(_id: string) {
|
public async run(_id: string) {
|
||||||
this.cronDb.find({ _id }).exec((err, docs) => {
|
this.cronDb.find({ _id }).exec((err, docs: Crontab[]) => {
|
||||||
let res = docs[0];
|
let res = docs[0];
|
||||||
|
|
||||||
this.logger.silly('Running job');
|
this.logger.silly('Running job');
|
||||||
|
@ -92,7 +92,13 @@ export default class CronService {
|
||||||
let logFile = `${config.manualLogPath}${res._id}.log`;
|
let logFile = `${config.manualLogPath}${res._id}.log`;
|
||||||
fs.writeFileSync(logFile, `${new Date().toString()}\n\n`);
|
fs.writeFileSync(logFile, `${new Date().toString()}\n\n`);
|
||||||
|
|
||||||
const cmd = spawn(`${res.command} now`, { shell: true });
|
let cmdStr = res.command;
|
||||||
|
if (res.command.startsWith('js')) {
|
||||||
|
cmdStr = `${res.command} now`;
|
||||||
|
} else if (/&& (.*) >>/.test(res.command)) {
|
||||||
|
cmdStr = res.command.match(/&& (.*) >>/)[1];
|
||||||
|
}
|
||||||
|
const cmd = spawn(cmdStr, { shell: true });
|
||||||
|
|
||||||
this.cronDb.update({ _id }, { $set: { status: CrontabStatus.running } });
|
this.cronDb.update({ _id }, { $set: { status: CrontabStatus.running } });
|
||||||
|
|
||||||
|
@ -141,7 +147,13 @@ export default class CronService {
|
||||||
const tabs = await this.crontabs();
|
const tabs = await this.crontabs();
|
||||||
var crontab_string = '';
|
var crontab_string = '';
|
||||||
tabs.forEach((tab) => {
|
tabs.forEach((tab) => {
|
||||||
if (tab.status !== CrontabStatus.disabled) {
|
if (tab.status === CrontabStatus.disabled) {
|
||||||
|
crontab_string += '# ';
|
||||||
|
crontab_string += tab.schedule;
|
||||||
|
crontab_string += ' ';
|
||||||
|
crontab_string += this.make_command(tab);
|
||||||
|
crontab_string += '\n';
|
||||||
|
} else {
|
||||||
crontab_string += tab.schedule;
|
crontab_string += tab.schedule;
|
||||||
crontab_string += ' ';
|
crontab_string += ' ';
|
||||||
crontab_string += this.make_command(tab);
|
crontab_string += this.make_command(tab);
|
||||||
|
|
|
@ -123,11 +123,12 @@ const Crontab = () => {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [isModalVisible, setIsModalVisible] = useState(false);
|
const [isModalVisible, setIsModalVisible] = useState(false);
|
||||||
const [editedCron, setEditedCron] = useState();
|
const [editedCron, setEditedCron] = useState();
|
||||||
|
const [searchText, setSearchText] = useState('');
|
||||||
|
|
||||||
const getCrons = (text: string = '') => {
|
const getCrons = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
request
|
request
|
||||||
.get(`${config.apiPrefix}crons?searchValue=${text}`)
|
.get(`${config.apiPrefix}crons?searchValue=${searchText}`)
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
setValue(data.data.sort((a: any, b: any) => a.status - b.status));
|
setValue(data.data.sort((a: any, b: any) => a.status - b.status));
|
||||||
})
|
})
|
||||||
|
@ -311,9 +312,13 @@ const Crontab = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSearch = (value: string) => {
|
const onSearch = (value: string) => {
|
||||||
getCrons(value);
|
setSearchText(searchText);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getCrons();
|
||||||
|
}, [searchText]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (document.body.clientWidth < 768) {
|
if (document.body.clientWidth < 768) {
|
||||||
setWdith('auto');
|
setWdith('auto');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user