0

I have an ubuntu server running with 2 node websites on it and I keep closing the terminals that start the app so I cannot shut the app down to make changes, I end up restarting the server.

How can I see what node instances are running and then stop them, or how do I stop a node instance through programming and I'll just make a button that kills the node instance. Either way...

1
  • 1
    In production you should use some process manager like github.com/foreverjs/forever or github.com/Unitech/pm2 both give you list of running processes and a allows you to start, stop and restart any of your apps Commented Nov 16, 2016 at 21:49

2 Answers 2

1

If you dont want to use PM2 or systemd you can get the list of all the node.js instances running using

ps -aux | grep node

once you have the list of all nodejs processes you can kill any process using kill command

kill "Process ID goes here"
Sign up to request clarification or add additional context in comments.

Comments

0

Use a process manager. PM2 is the most widely recommended.

npm install pm2@latest -g

then

pm2 start app.js

Alternatively you can use something like screen to have multiple terminal sessions running in one window

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.