diegoaguilar
diegoaguilar

Reputation: 8376

How to manage distinct node.js apps running at a VPS?

I have multiple node.js apps running at my VPS, and I access to it through ssh. Right now I start them in the way:

nohup node server.js

That looks good but I get whole logs to nohup.out, and what's more important and not efficient is about restarting of stopping them.

If I do ps -A | grep node I will get an output like:

 9172 ?        00:00:01 node
 9178 ?        00:00:00 node
 ...

So, how can I identify them?

I also knew about nodemon and it's great! But however logging out ssh breaks the magic.

I think maybe some more advanced tools would help out. What's the best approach for this?

Just in case, I use Nginx on top (port 80) and do reverse proxy, but I'd be ok changing that.

Upvotes: 0

Views: 126

Answers (2)

Remy Sharp
Remy Sharp

Reputation: 4560

You can run nodemon under --quiet mode and it'll suppress all nodemon output (and keep your logging working).

Upvotes: 1

dylants
dylants

Reputation: 23430

One solution (there are many) is pm2: https://github.com/Unitech/pm2

It's a process manager for node, and comes with a variety of features, some of which include the ability to spread your app across multiple CPU cores while providing an easy TTY management view of the applications. It also has the ability to reload the apps without stopping them.

If the readme's not sufficient, I found this post useful in understanding the basics: http://devo.ps/blog/2013/06/26/goodbye-node-forever-hello-pm2.html

Upvotes: 1

Related Questions