Restir
Restir

Reputation: 149

Jenkins with PM2 - issue with possibility to enter to the running server

Got issue regarding pm2. Right now I've got a Jenkins that should build an application during each commit. Everything works fine. In the pipeline, Jenkins should start a server with PM2.

Right now Jenkins has got access to pm2 and everything works smoothly. Unfortunately, the issue is when I'm on the user "test" and write pm2 ls - I see an empty list of processes.

And this is causing some issues because my nginx is not able to detect working applications so I receive "502".

In Jenkins, when I write pm2 ls I see that process works fine. Also tried it with sudo pm2 start and then in the console sudo pm2 ls - in such case, I see the process, but in the jenkins, the status is success but in the terminal - it's errored` and also nginx does not see that server.

Also important information, that when I type the command: pm2 start "npm run start-prod" --name myAppName - the process is seen in test user and the nginx also works fine.

Do you know how can I settle the PM2 with Jenkins and set the process to be "global" and seen by the "test" user?

Upvotes: 0

Views: 473

Answers (1)

Restir
Restir

Reputation: 149

To make it - I should use --watch flag in pm2. That allow me to watch the changes in the file and run it via test user.

Upvotes: 0

Related Questions