2

I have a node chat application that needs to keep running on my server (ubuntu with nginx). The problem is that the application stops after a few days without any error. When I check on the server I see that my pm2 list is empty.

The code I use to start my app:

cd myapp
pm2 start npm --name='backend' -- start

It somehow looks as if pm2 is reset after a while. But I'm trying to keep running it forever, but then I run into the same problem. Is there some way to prevent the pm2 list from getting empty?

I run the same cmd to start it and again its happening.I want to keep running the pm2 process in my server without stopping automatically.

1
  • Could you share your start command ? Commented Sep 17, 2024 at 3:20

1 Answer 1

1

Consider checking the uptime of your server to see if it restarted for some reason and interrupted the pm2 process.

If this is the case, you can run pm2 startup and it will take a snapshot of your current processes and start them automatically when the server starts.

If you update the pm2 process, add another one, etc., run pm2 save to update the startup process list.

When running pm2 startup without sudo privileges, you will need to paste a command to update an environment variable, read more on this here.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks I have done this solution. But this issue like once after a long time. Lets watch if its happening again👍

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.