GOCD Agent on Linux(Ubuntu) giving error when trying to run service using PM2

52 Views Asked by At

I am newer to using Linux(Ubuntu) and GOCD. I have installed GOCD Agent and PM2 on LINUX(Ubuntu) VM for a Node JS app and trying to run PM2 restart command from GOCD Agent. But it is giving error -

[go] Task: pm2 restart my-app Use --update-env to update environment variables [PM2][ERROR] Process or Namespace my-app not found [go] Task status: failed, took: 0.181s, exited: 1 [go] Current job status: failed

Firstly I added above task in PM2 using my user but error was same. Then I tried to add above task using PM2 by sudo user. But error is same in both cases.

1

There are 1 best solutions below

0
Pramod Kumar On

This issue was because PM2 was running from one user while GOCD has its own user running named 'go'. To solve this issue, I followed below steps -

  1. Add a group named 'pm2'.
  2. Add your user to this group.
  3. Execute PM2 from your user.
  4. Add 'go2. Given all permissions to that group so that any group user can access PM2.
  5. Added 'go' user in 'pm2' group so that go user can access PM2 services/apps.
  6. In GOCD, add environment variable in pipeline stage as - PM2_HOME = /YOUR_PATH_OF_PM2