-
Notifications
You must be signed in to change notification settings - Fork 30
/
run-cli.js
executable file
·38 lines (27 loc) · 842 Bytes
/
run-cli.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
#!/usr/bin/env node
'use strict';
var forever = require('forever-monitor');
var path = require('path');
var restartCount = 0;
var sqsdProcess = new (forever.Monitor)(path.join(__dirname, 'cli.js'), {
fork: true,
max: 1000,
minUptime: 22000,
args: process.argv.slice(2)
});
sqsdProcess.on('error', function (err) {
console.error( {err:err}, 'Error caused SQSD to crash.');
});
sqsdProcess.on('restart', function () {
console.warn({restartCount:restartCount}, 'It is likely that an error caused SQSD to crash.');
++restartCount;
});
sqsdProcess.on('exit', function () {
console.info('SQSD stopped.');
});
sqsdProcess.start();
process.on('SIGTERM', () => {
console.info('SIGTERM signal received, graceful shutdown sqsd');
sqsdProcess.forceStop = true;
sqsdProcess.send({action: 'shutdown'});
});