This commit is contained in:
chaosBreaking
2019-10-15 15:01:43 +08:00
parent cd7d093fc7
commit 3aaf9244fc
2 changed files with 5 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ const { inject } = require('../common/Provider');
const Agenda = require('agenda'); const Agenda = require('agenda');
const mongoose = require('mongoose'); const mongoose = require('mongoose');
const mountJobs = require('./jobs'); const mountJobs = require('./jobs');
const exec = require('child_process').exec;
module.exports = () => inject(async function startJob(SysConfig) { module.exports = () => inject(async function startJob(SysConfig) {
const { DB_USER_NAME, DB_PASSWD, DB_HOST, DB_PORT, DB_NAME } = SysConfig; const { DB_USER_NAME, DB_PASSWD, DB_HOST, DB_PORT, DB_NAME } = SysConfig;
@@ -18,5 +19,8 @@ module.exports = () => inject(async function startJob(SysConfig) {
mountJobs(Job); mountJobs(Job);
await Job.start(); await Job.start();
mylog.info('任务队列启动...'); mylog.info('任务队列启动...');
// app.use('/admin/myAgendash', Agendash(Job));
exec(`npx agendash --db=mongodb://${DB_USER_NAME}:${DB_PASSWD.replace('&', `\\&`)}@${DB_HOST}:${DB_PORT}/${DB_NAME} --collection=agendaJobs --port=6057`);
mylog.info('agendash启动...');
return Job; return Job;
}); });

View File

@@ -170,7 +170,7 @@ const jobs = [
// timezone: "ETC/GMT+8" // timezone: "ETC/GMT+8"
// }, // },
{ {
name: 'mine', name: 'mineCorn',
processor: mineJob, processor: mineJob,
type: 'every', type: 'every',
slot: '0 0 2 * * *', slot: '0 0 2 * * *',