-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.js
47 lines (37 loc) · 1.36 KB
/
start.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
42
43
44
45
46
47
/* Import NPM Modules */
var $ = require("jquery");
var fs = require('node-fs');
var config = require('./config');
var forever = require('forever-monitor');
/* Create Logs Folder */
fs.mkdirSync(__dirname + '/../logs/' + config.forever.uid, 0775, true);
/* Configure Forever (Daemon & File Watcher) */
var child = new (forever.Monitor)(__dirname + '/server.js', {
uid: config.forever.uid,
max: config.forever.max_failures,
silent: config.forever.silent,
spinSleepTime: 10,
watch: (config.general.production) ? false : config.forever.watch,
watchDirectory: __dirname + "/" + config.forever.watch_directory,
watchIgnoreDotFiles: config.forever.watch_ignore_dot,
watchIgnorePatterns: $.map(config.forever.watch_ignore_patterns, function(value) {
return __dirname + "/" + value;
}),
env: {
'NODE_ENV': (config.general.production) ? "production" : "development"
},
outFile: __dirname + "/" + config.forever.output_log,
errFile: __dirname + "/" + config.forever.error_log,
killTree: true
});
/* Log on Exit */
child.on('exit', function () {
console.log("server.js fully down after " + config.forever.max_failures + " starts.");
console.log("SERVER DOWN.");
});
/* Log Exit Code */
child.on('exit:code', function(code) {
console.log("server.js exited with code " + code);
});
/* Start Forver */
child.start();