Breaking

Running a Node.js Server Forever


Running a Node.js Server Forever

A simple CLI tool for ensuring that a given node script runs continuously (i.e. Forever)



var http = require('http');
var server = http.createServer(function (request, response) {
  if (request.url === '/') {
    response.setHeader('Content-Type', 'text/html');
    response.end('<strong>obligatory bear!</strong>');
  }
});

server.listen(8080, function () {
  console.log('Im listening on port 8080');
});

To start the server you need to rum following command

forever start app.js(whatever you file name );

and also you can write this command to system file name rs.local


No comments:

Powered by Blogger.