-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestAgendaRun.js
58 lines (41 loc) · 1.08 KB
/
testAgendaRun.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Created by chaclus on 16/9/3.
*/
var Agenda = require('agenda');
var mongoConnectionString = "mongodb://192.168.3.30/agenda";
/*
var agenda = new Agenda({db: {address: mongoConnectionString}}, function () {
query()
});
*/
var agenda = new Agenda({db: {address: mongoConnectionString}});
var page = 1;
var size = 10;
agenda.on("start", function (job) {
console.log('Job %s run .', job.attrs.name);
});
agenda.on("complete", function (job) {
console.log('Job %s finished ', job.attrs.name);
});
agenda.on('success', function(job) {
console.log("Successfully to: %s", job.attrs.name);
});
agenda.on('fail', function(err, job) {
console.log("Job failed with error: %s", err.message);
});
var hello = function (cb) {
console.log("==========Job is running=========")
cb();
};
var query = function () {
//{name: 'show'}
var q = {name:'new_21'};
agenda.jobs(q, function (err, jobs) {
console.log(jobs);
if(jobs.length > 0) {
jobs[0].enable()
jobs[0].save();
}
});
};
setTimeout(query, 3000);