mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-24 07:16:08 +08:00
修复ql update状态异常
This commit is contained in:
parent
7aefcaf75e
commit
ed9db7c8d5
|
@ -5,7 +5,7 @@ import CronService from '../services/cron';
|
||||||
const initData = [
|
const initData = [
|
||||||
{
|
{
|
||||||
name: '更新面板',
|
name: '更新面板',
|
||||||
command: `sleep ${randomSchedule(60, 1)} && ql update`,
|
command: `ql update`,
|
||||||
schedule: `${randomSchedule(60, 1)} ${randomSchedule(
|
schedule: `${randomSchedule(60, 1)} ${randomSchedule(
|
||||||
24,
|
24,
|
||||||
7,
|
7,
|
||||||
|
@ -31,6 +31,7 @@ export default async () => {
|
||||||
const cronDb = cronService.getDb();
|
const cronDb = cronService.getDb();
|
||||||
|
|
||||||
cronDb.count({}, async (err, count) => {
|
cronDb.count({}, async (err, count) => {
|
||||||
|
if (count === 0) {
|
||||||
const data = initData.map((x) => {
|
const data = initData.map((x) => {
|
||||||
const tab = new Crontab(x);
|
const tab = new Crontab(x);
|
||||||
tab.created = new Date().valueOf();
|
tab.created = new Date().valueOf();
|
||||||
|
@ -42,11 +43,20 @@ export default async () => {
|
||||||
}
|
}
|
||||||
return tab;
|
return tab;
|
||||||
});
|
});
|
||||||
if (count === 0) {
|
|
||||||
cronDb.insert(data);
|
cronDb.insert(data);
|
||||||
await cronService.autosave_crontab();
|
await cronService.autosave_crontab();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cronDb.find({ name: '更新面板' }).exec((err, docs) => {
|
||||||
|
const doc = docs[0];
|
||||||
|
if (doc && doc.status === CrontabStatus.running) {
|
||||||
|
cronDb.update(
|
||||||
|
{ name: '更新面板' },
|
||||||
|
{ $set: { status: CrontabStatus.idle } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function randomSchedule(from: number, to: number) {
|
function randomSchedule(from: number, to: number) {
|
||||||
|
|
|
@ -255,10 +255,11 @@ update_qinglong() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $exit_status -eq 0 ]]; then
|
if [[ $exit_status -eq 0 ]]; then
|
||||||
echo -e "重启青龙面板...\n"
|
echo -e "重启青龙面板(后台重启)...\n"
|
||||||
cd $dir_root
|
cd $dir_root
|
||||||
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
||||||
echo -e "重启面板完成...\n"
|
echo -e "重启面板完成(请5s后刷新页面)..."
|
||||||
|
pm2 reload all
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user