Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
logger.info(t('libraries:scheduler.systemTask', {
name,
}));
systemJobs.push(name);
}
// Pass the new job to the scheduler
scheduler.scheduleJob(name, time, callback);
};
// Export functions
module.exports = {
schedule,
clear,
RecurrenceRule: scheduler.RecurrenceRule,
jobs: scheduler.scheduledJobs,
Range: scheduler.Range,
};
const schedule = (name, time, callback, system) => {
// Job already exists
if (_.includes(scheduler.scheduledJobs, name)) {
logger.warn(t('libraries:scheduler.duplicate', {
name,
time,
}));
return;
}
// Callback is missing
if (!_.isFunction(callback)) {
logger.warn(t('libraries:scheduler.missingCallback', {
name,
}));
return;
}
// If this is a system job, keep track so we do not purge during reload
if (system === true) {
conn.query('select * from autofood', function(err,rows,fields){
let len = rows.length;
let tem = rows[len-1].type;
if (tem !== x) {
if (schedule.scheduledJobs['feed']) {
var result = schedule.cancelJob('feed');
console.log("关闭当前定时: ")
console.log(result)
}
big()
}else{
console.log("same")
}
})
}
conn.query('select * from autofood',function(err,rows,fields){
var i = rows.length;
var tem = rows[i-1].type;
console.log(tem);
change(tem)
console.log(schedule.scheduledJobs)
setInterval(function(){
check(tem)
},3000)
})
}
reShedulJob: function (jobName, start_date, end_date, cron_exp) {
let cron_expression = {
start: moment(start_date).toDate(),
end: moment(end_date).toDate(),
rule: cron_exp
};
all_jobs = scheduler.scheduledJobs;
result = all_jobs[jobName].reschedule(cron_expression);
return result;
}
}
const clear = () => _.forEach(scheduler.scheduledJobs, (job) => {
if (!_.includes(systemJobs, job.name)) {
job.cancel();
}
});
cancleJob: function (jobName) {
all_jobs = scheduler.scheduledJobs
if (jobName in all_jobs) {
all_jobs[jobName].cancel()
return true
}
else {
return false;
}
},
reShedulJob: function (jobName, start_date, end_date, cron_exp) {