Installation
$ [sudo] npm install forever -g
Example code
index.js
var http = require("http");
http.createServer(function (request, response) {
// Send the HTTP header
// HTTP Status: 200 : OK
// Content Type: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body as "Hello World"
response.end('Hello World\n');
}).listen(8081);
// Console will print the message
console.log('Server running at http://127.0.0.1:8081/');
USAGE
If you want to run any program for a while then you can use this plugin .1)Start
For running program with forever use below command
forever start index.js
NOw go to browser and type
http://127.0.0.1:8081/
you will get result as Hello World.
2) Stop
For stopping your programme
forever stop index.js
3)Logs
You can also check logs
type below command
forever logs
it will give you log file path stored on your machine so you can go to that location and view file.
No comments:
Post a Comment