mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-27 14:46:06 +08:00
更新青龙重启逻辑
This commit is contained in:
parent
1f565b31da
commit
748d00ae45
|
@ -1,13 +1,15 @@
|
|||
import schedule from 'node-schedule';
|
||||
import DataStore from 'nedb';
|
||||
import config from './config';
|
||||
import { exec } from 'child_process';
|
||||
import Logger from './loaders/logger';
|
||||
|
||||
const db = new DataStore({ filename: config.cronDbFile, autoload: true });
|
||||
import { Container } from 'typedi';
|
||||
import CronService from './services/cron';
|
||||
|
||||
const run = async () => {
|
||||
db.find({})
|
||||
const cronService = Container.get(CronService);
|
||||
const cronDb = cronService.getDb();
|
||||
|
||||
cronDb
|
||||
.find({})
|
||||
.sort({ created: 1 })
|
||||
.exec((err, docs) => {
|
||||
if (err) {
|
||||
|
|
|
@ -190,6 +190,8 @@ export default class CronService {
|
|||
const tabs = await this.crontabs();
|
||||
var crontab_string = '';
|
||||
tabs.forEach((tab) => {
|
||||
const _schedule = tab.schedule && tab.schedule.split(' ');
|
||||
if (_schedule && _schedule.length === 5) {
|
||||
if (tab.status === CrontabStatus.disabled) {
|
||||
crontab_string += '# ';
|
||||
crontab_string += tab.schedule;
|
||||
|
@ -202,13 +204,14 @@ export default class CronService {
|
|||
crontab_string += this.make_command(tab);
|
||||
crontab_string += '\n';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.logger.silly(crontab_string);
|
||||
fs.writeFileSync(config.crontabFile, crontab_string);
|
||||
|
||||
execSync(`crontab ${config.crontabFile}`);
|
||||
execSync(`pm2 restart schedule`);
|
||||
exec(`pm2 restart schedule`);
|
||||
this.cronDb.update({}, { $set: { saved: true } }, { multi: true });
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
|||
&& rm -rf /root/.npm \
|
||||
&& yarn install --network-timeout 100000 \
|
||||
&& yarn build \
|
||||
&& yarn build-back \
|
||||
&& yarn install --production --network-timeout 100000 \
|
||||
&& yarn cache clean
|
||||
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
|
@ -321,16 +321,17 @@ restart_qinglong() {
|
|||
echo -e "重新编译青龙...\n"
|
||||
yarn install --network-timeout 1000000000 || yarn install --registry=https://registry.npm.taobao.org --network-timeout 1000000000
|
||||
yarn build
|
||||
yarn build-back
|
||||
yarn cache clean
|
||||
echo -e "重新编译青龙完成...\n"
|
||||
|
||||
echo -e "重启青龙面板...\n"
|
||||
pm2 restart panel 2>/dev/null || pm2 start npm -n panel -- run panel
|
||||
pm2 restart panel 2>/dev/null || pm2 start $dir_root/build/app.js -n panel
|
||||
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
||||
echo -e "重启面板完成...\n"
|
||||
|
||||
echo -e "重启定时任务...\n"
|
||||
pm2 restart schedule 2>/dev/null || pm2 start npm -n schedule -- run schedule
|
||||
pm2 restart schedule 2>/dev/null || pm2 start $dir_root/build/schedule.js -n schedule
|
||||
echo -e "重启定时完成...\n"
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user