0

I am working on a Node.js project. It was working fine on the previous server with the command npx pm2 start ./bin/www using PM2.

Now, I have an AlmaLinux server where I am trying to run my Node.js application. However, when I close the terminal the PM2 instance is removed from the list and the application stops working.

I attempted to solve this problem by adding a restart time, but the same issue occurred — the instance was removed upon closing the terminal.

I also tried using the nohup pm2 start ./bin/www command. I came across the nohup command, which is supposed to ensure that the process continues running even if the SSH session is terminated.

Please avoid marking this question as a duplicate, as it is distinct from others already present near the blocking list.

opeonikute
  • 494
  • 1
  • 4
  • 15
majid
  • 23
  • 8
  • Does this answer your question? [How do I run a node.js app as a background service?](https://stackoverflow.com/questions/4018154/how-do-i-run-a-node-js-app-as-a-background-service) – opeonikute Aug 30 '23 at 09:12

1 Answers1

0

Try to use pm2 startup

This command configures the appropriate system service manager (such as systemd on Linux) to start pm2 and your Node.js application on system startup. After running this command, your Node.js application managed by pm2 will automatically start and be monitored by pm2 whenever the system boots up