Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs service stops automatically

we are working on project where we have used node-js in background socket for continues respond to web application. In between sometimes somehow some process stops automatically.

We would like to know how we can check all the process running using forever.

We are using sudo forever list to list all process. Is there any way to use this command(forever list) in .sh(shell script file) to check my specific process like responsclient is working or not. If that particular process is not working then we needs to start that.

like image 837
Rushabh Madhu Avatar asked Mar 18 '26 12:03

Rushabh Madhu


1 Answers

There are several solutions that will ensure that your service is always running.

One of them is even called forever. Here you have an overview prepared by express.

However, for production services I recommend passenger The result is almost the same, but much greater scalability. For example, you can configure so that another instance is automatically added.

Almost - because it is designed to ensure the availability of HTTP, and not the constant operation of the application.

BTW: service stops, because you have uncatched exception.

Update

If you insist on forever, then: (We're talking about the same forever?)

  • Make sure that forever is run by the same user. forever has separate managers for all users.
  • Make sure you save your data in the same place. (automatic run eg by cron is different from manual startup (vaiables in env))
  • forever has --pidFile - then it is very easy to check if the process is working
  • also ps -aux | grep node should be your big friend.

No, I do not have it combined. When I started to have problems, I switched to passenger. Finally I did it well because I have professional monitoring, which I launched in less time than searching how to combine the above points together.

like image 165
bato3 Avatar answered Mar 21 '26 01:03

bato3



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!