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 schedule from 'node-schedule';
|
||||||
import DataStore from 'nedb';
|
|
||||||
import config from './config';
|
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import Logger from './loaders/logger';
|
import Logger from './loaders/logger';
|
||||||
|
import { Container } from 'typedi';
|
||||||
const db = new DataStore({ filename: config.cronDbFile, autoload: true });
|
import CronService from './services/cron';
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
db.find({})
|
const cronService = Container.get(CronService);
|
||||||
|
const cronDb = cronService.getDb();
|
||||||
|
|
||||||
|
cronDb
|
||||||
|
.find({})
|
||||||
.sort({ created: 1 })
|
.sort({ created: 1 })
|
||||||
.exec((err, docs) => {
|
.exec((err, docs) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -190,17 +190,20 @@ 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) {
|
const _schedule = tab.schedule && tab.schedule.split(' ');
|
||||||
crontab_string += '# ';
|
if (_schedule && _schedule.length === 5) {
|
||||||
crontab_string += tab.schedule;
|
if (tab.status === CrontabStatus.disabled) {
|
||||||
crontab_string += ' ';
|
crontab_string += '# ';
|
||||||
crontab_string += this.make_command(tab);
|
crontab_string += tab.schedule;
|
||||||
crontab_string += '\n';
|
crontab_string += ' ';
|
||||||
} else {
|
crontab_string += this.make_command(tab);
|
||||||
crontab_string += tab.schedule;
|
crontab_string += '\n';
|
||||||
crontab_string += ' ';
|
} else {
|
||||||
crontab_string += this.make_command(tab);
|
crontab_string += tab.schedule;
|
||||||
crontab_string += '\n';
|
crontab_string += ' ';
|
||||||
|
crontab_string += this.make_command(tab);
|
||||||
|
crontab_string += '\n';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -208,7 +211,7 @@ export default class CronService {
|
||||||
fs.writeFileSync(config.crontabFile, crontab_string);
|
fs.writeFileSync(config.crontabFile, crontab_string);
|
||||||
|
|
||||||
execSync(`crontab ${config.crontabFile}`);
|
execSync(`crontab ${config.crontabFile}`);
|
||||||
execSync(`pm2 restart schedule`);
|
exec(`pm2 restart schedule`);
|
||||||
this.cronDb.update({}, { $set: { saved: true } }, { multi: true });
|
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 \
|
&& rm -rf /root/.npm \
|
||||||
&& yarn install --network-timeout 100000 \
|
&& yarn install --network-timeout 100000 \
|
||||||
&& yarn build \
|
&& yarn build \
|
||||||
|
&& yarn build-back \
|
||||||
&& yarn install --production --network-timeout 100000 \
|
&& yarn install --production --network-timeout 100000 \
|
||||||
&& yarn cache clean
|
&& yarn cache clean
|
||||||
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
|
@ -321,16 +321,17 @@ restart_qinglong() {
|
||||||
echo -e "重新编译青龙...\n"
|
echo -e "重新编译青龙...\n"
|
||||||
yarn install --network-timeout 1000000000 || yarn install --registry=https://registry.npm.taobao.org --network-timeout 1000000000
|
yarn install --network-timeout 1000000000 || yarn install --registry=https://registry.npm.taobao.org --network-timeout 1000000000
|
||||||
yarn build
|
yarn build
|
||||||
|
yarn build-back
|
||||||
yarn cache clean
|
yarn cache clean
|
||||||
echo -e "重新编译青龙完成...\n"
|
echo -e "重新编译青龙完成...\n"
|
||||||
|
|
||||||
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
|
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
||||||
echo -e "重启面板完成...\n"
|
echo -e "重启面板完成...\n"
|
||||||
|
|
||||||
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"
|
echo -e "重启定时完成...\n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user