3

I have next.js application on an apache server.I was running npm run start in my terminal and it is working as expected, starting build website. problem is that when I close terminal, service stops. I know that I have to use pm2 for that and I have installed it globally, problem is that it is not running. am trying this command

pm2 start npm --name "khulo" -- start

my application name is "khulo". this is the output I get from terminal:

enter image description here

therefore as far as I understand, there is no process and therefore there is no service on my server. what is the problem? am running that command in my root project

edit: I know that I need priviliges as an user to start pm2, but am not root user, therefore now am asking what privillege do I need as a non-root user to control pm2?

2 Answers2

0

Have you try this:

pm2 start "npm run start" --name "khulo"

More informations: https://pm2.keymetrics.io/docs/usage/process-management/

If you need to start as root:

sudo pm2 start "npm run start" --name "khulo"
Alaindeseine
  • 3,260
  • 1
  • 11
  • 21
0

I have a nextjs app running with the same command that is connected to the nodejs backend. I start with the sudo permissions by running sudo su

pm2 start npm --name "khulo" --start

To start with the non-root user, try the following link

https://stackoverflow.com/a/65461743

Sandy M
  • 138
  • 7