I am currently using forever-monitor to spawn a basic HTTP Node Server, although when I execute the JavaScript that executes the forever-monitor scripts, it isn't sent to the background, when I exit the TTY session, the HTTP server stops.
The code I am using to spawn the server follows.
The question I am asking really is, should I be using Forevers CLI to spawn the script that spawns subsequent servers programatically?
var forever = require('forever-monitor');
var child = new (forever.Monitor)('streams.js', {
max: 3,
silent: true,
options: []
});
child.on('exit', function () {
console.log('streams.js has exited after 3 restarts');
});
child.start();
You can either start that script with forever by running
forever start [your-script.js]
or if you don't want to install Forever's CLI you can just run
nohup node [your-script.js] > nohup.log &