0

I wasn't quite sure what to call this question but here i go:

i have a remote server where i have installed node.js now normally this would be how i start the server:

ssh root@ip
cd /var/www/mydomain/server
nodejs server.js

This works without any issues however what happens when i close down the terminal? How can i make sure that the server doesn't just stop. And how can i control it after i have started it (for instance restarting / stopping it).

Marc Rasmussen
  • 19,771
  • 79
  • 203
  • 364
  • possible duplicate of [Node.js as a background service](http://stackoverflow.com/questions/4018154/node-js-as-a-background-service) – anvarik Feb 06 '15 at 11:20

1 Answers1

1

There are plenty of solutions here, but maybe the most easy to start with is using forever.

Forever is a npm module that keep your app running and restarts it if it crashes.

Also there are more advanced solutions, like using PM2, which I recommend, but first take a look at forever.

Kangcor
  • 1,179
  • 1
  • 16
  • 26