Question

In my application i want to restart my node js server programmatically.For that i need to install forever-monitor while installing that module using npm im getting error as "No compatible version found: forever-monitor".My node version is v 0.6.17.Can anyone help to fix this issue.

Was it helpful?

Solution

You need to upgrade to 0.8 atleast. forever-monitor requires node 0.8.x. See here.

You can check the node version required for a particular package by looking for engine field

npm view forever-monitor

{ name: 'forever-monitor',
  description: 'Core forever process monitor',
  'dist-tags': { latest: '1.1.0' },
...
engines: { node: '0.8.x' },

OTHER TIPS

Can you upgrade to at least node 0.8? Node.js is now on 0.10.2 so 0.6 is pretty old and many modules are no longer supporting 0.6.

Forever and forever-monitor both work very well in 0.8. The nodejitsu team is working on making forever compatible with 0.10 so that should happen soon.

Also have you looked at https://github.com/substack/fleet? Fleet is an excellent way to manage deployments and running processes.

To restart your server you don't need forever. Just create, close and create the server. A small example:

var http = require('http');

var server = startServer();
// ...
server = restartServer(server);
// ...
server = restartServer(server);

function startServer() {
  return http.createServer(server).listen(server.get('port'), function(){
    console.log("Server listening on port " + server.get('port'));
  });
}

function restartServer(server) {
  server.close();
  return startServer();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top