Noob Question: How to keep node running on DigitalOcean?

I set my MEAN (non-meteor) app up on a MEAN image on digital ocean. I can ssh in and start it with

NODE_ENV=production PORT=80 node server.js

But when I close my terminal, the SSH session terminates and node stops running (obviously, I guess). I’d like it running 24 hrs/day like a normal production app.

I’ve only ever used galaxy where I just deploy and the app is there running… no need to keep ssh open. How do you get the same result with a MEAN app on digital ocean?

Note: this isn’t a production app, it’s just a practice/portfolio app. I don’t need an enterprise-level solution, just the quick and dirty way to get it up there. I’ve seen on SO talk about a npm ‘forever’ package, a “screen” package and a couple other things… what do I do?!

I’m kind of flabbergasted there isn’t a straightforward way to do this…

Anytime i do anything outside of meteor + galaxy, I wonder why anybody does anything outside of meteor + galaxy!

There are few answers here but they seem kind of esoteric to me:

I’ve done everything outside of Meteor + Galaxy… which is why I’m now coming to it. :slight_smile:

I’ve had the best luck with PM2.

That should be perfect for your practice. If you want to move further, you need to make PM2 spin up on server restart and load your node server. For that, look into upstart.

This is probably not the best place to ask for non-meteor related things, but you’ll probably be able to manage it using:

1 Like

nohup node blah.js &

1 Like

PM2 worked great!