-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathworker.js
More file actions
44 lines (39 loc) · 1.07 KB
/
worker.js
File metadata and controls
44 lines (39 loc) · 1.07 KB
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
'use strict';
var executor = require('./common/executor.js');
var poller = require('./common/poller.js');
var util = require('util');
module.exports = function () {
var who = util.format('%s|%s', global.who, 'worker');
logger.info(who, 'Inside');
var pollerOpts = {
filePath: global.config.jobWhoPath,
intervalMS: global.config.pollIntervalMS,
content: 'reqKick'
};
poller(pollerOpts,
function (err, handoffPoll) {
if (err) {
logger.error(
util.format('%s: Failed to setup poller with error: %s', who, err)
);
} else {
handoffPoll.on('match', function () {
logger.verbose(
util.format('%s: Received handoff. Stopping poll. ' +
'Starting execution.', who
)
);
handoffPoll.stop();
executor(
function () {
handoffPoll.watch();
logger.verbose(
util.format('%s: Execution complete. Starting poll again.', who)
);
}
);
});
}
}
);
};