I am running node using putty. but it doesn't work when putty session expire. How can I start node js permanently, should not be terminated if putty session end.
7 Answers
I just solved that issue yesterday using Forever > http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever
It's awesome.
For Installing:
npm install ForverFor running:
forever start yourServer.jsFor checking if its running:
forever list
cool eh?
1 Comment
Among what Raynos and nEEbz are suggesting you can also try to use GNU Screen. This is very handy especially if you are using putty to connect to remote server. Check out this screen tutorial for more information.
Comments
Here is a quick and gentle introduction to "screen" .
In ubuntu, if you need to install it, use: apt-get install screen
First use:
$ screen
bunch of stuff prints out, then another shell prompt
$ node ./myapp.js
now your node app is running
You want to edit some other code?
control-a c
the window clears, and you now have another shell prompt. node is still running....
$ edit public/somewebfile.html
save it, still in editor go back to node
control-a control-a
screen switches back to the screen running node
need to leave the office for a few minutes
control-a control-d
(screen detaches from your location... processes remain attached)
$ logout
screen disconnects, but nodejs and the editor are still running...
back at home... want to connect to work
> ssh work.some.where
> screen -D -R
screen reconnecting....
now you see the nodejs shell screen again, or control-a control-a to switch back to that editor
control-a ? shows available commands, or read the nice man page: man screen
Comments
If you get an error when you do npm install Forever, do npm install forever -g
I got that problem.
Comments
Use PM2
just install pm2 on the server and run app like this : pm2 start app.js
you can also monitor your application from the web panel