-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.js
More file actions
39 lines (28 loc) · 845 Bytes
/
worker.js
File metadata and controls
39 lines (28 loc) · 845 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
32
33
34
35
36
37
38
39
'use strict';
/**
* @name worker
* @description job worker process for open311 API
*
* Alert!: Please ensure your have installed Redis Server
*
* Alert!: Run worker in the separate process from main process
*
* Recommendation!: It also adviced to run each worker per process or per machine
* with any number of concurrency(10 is sufficient max worker so far)
*/
const { getNumber } = require('@lykmapipo/env');
const { worker, listen } = require('@lykmapipo/postman');
const mkdir = require('mkdir-p');
/* constants */
const KUE_HTTP_PORT = getNumber('KUE_HTTP_PORT');
//build logs directory if does not exists
const logPath = './logs';
mkdir.sync(logPath);
/* setup models */
require('./app/initializers/mongoose');
/* run work */
worker.start();
/* open web interface to monitor jobs */
if (KUE_HTTP_PORT) {
listen();
}