forked from Flolagale/mailin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-cli.js
executable file
·41 lines (32 loc) · 1001 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
39
40
41
#!/usr/bin/env node
'use strict';
var forever = require('forever-monitor');
var logger = require('./lib/logger');
var path = require('path');
var pkg = require('./package.json');
var restartCount = 0;
var mailinProcess = new (forever.Monitor)(path.join(__dirname, 'cli.js'), {
max: 1000,
minUptime: 10000,
args: process.argv.slice(2)
});
mailinProcess.on('error', function (err) {
logger.error('Error caused Mailin to crash.');
logger.error('Please report this to ' + pkg.bugs.url);
logger.error(err);
logger.info();
logger.info();
});
mailinProcess.on('restart', function () {
logger.warn('It is likely that an error caused Mailin to crash.');
logger.warn('Please report this to ' + pkg.bugs.url);
logger.warn('Mailin restarted.');
++restartCount;
logger.warn('Restart count: ' + restartCount);
logger.info();
logger.info();
});
mailinProcess.on('exit', function () {
logger.info('Mailin stopped.');
});
mailinProcess.start();