-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcronjobs.js
More file actions
31 lines (24 loc) · 922 Bytes
/
cronjobs.js
File metadata and controls
31 lines (24 loc) · 922 Bytes
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
/**
* Run all cronjobs
* https://devcenter.heroku.com/articles/scheduled-jobs-custom-clock-processes
* https://www.npmjs.com/package/cron
* This is the clock process on heroku
*
* !Important: Should only have 1 dyno process running for this. heroku ps:scale clock=1
*/
'use strict';
// ENV variables
const { NODE_ENV } = process.env;
// third party node modules
const CronJob = require('cron').CronJob;
const queue = require('./services/queue'); // Queue Service for Background Jobs
// Print Process Info
console.log(`CLOCK process.pid: ${process.pid}`);
console.log(`CLOCK process.env.NODE_ENV: ${NODE_ENV}`);
/*****************/
/***** ADMIN *****/
/*****************/
const AdminQueue = queue.get('AdminQueue');
// Example automatically make request. Run every 1 min.
// new CronJob('0 0 * * * *', () => { AdminQueue.add('V1ExportTask', { adminId: 1 }); }, null, true, 'UTC');
// add future cronjobs here