forked from moudy/agenda-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.js
48 lines (37 loc) · 1.12 KB
/
dev.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
var express = require('express');
var Agenda = require('agenda');
var agendaUI = require('./index');
var app = express();
var agenda = new Agenda({db: { address: 'localhost:27017/agenda-ui-development'}});
agenda._db.remove(function () {
agenda.define('Send Email', {priority: 'highest'}, function(job, done) {
console.log('Send Email', job.attrs.data);
setTimeout(done, 1000);
});
agenda.define('Delete Users', function(job, done) {
console.log('Delete users', job.attrs.data);
setTimeout(done.bind(null, new Error('Error deleting users')), 3000);
});
agenda.define('Run Analytics', function(job, done) {
console.log('Run Analytics', job.attrs.data);
setTimeout(done, 2000);
});
agenda.schedule('in 25 seconds', 'Send Email', {
to: '[email protected]'
, subject: 'Report'
});
agenda.every('18 seconds', 'Delete Users', {
inactive: true
, paying: false
});
agenda.every('1 minute', 'Run Analytics', {
type: 'engagement'
, email: 'team'
});
app.use('/', agendaUI(agenda, {
poll: 2000
, ASSET_HOST: '//localhost:4200'
}));
agenda.start();
app.listen(3022);
});