-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PM2_HOME lost in webhook #2756
Comments
Could you check that you had only one daemon running ? |
That points to multiple daemons I think. How to clean that up if that's the case? |
Just kill the daemon that doesn't old any process (should be the one under root) |
we have killed that root daemon, but still it fails as described |
Pretty sure the env variable didn't propagated to child process, could you try restarting them to pick-up the changes ? |
So what I did right now:
` /var/log/frontend/WEBHOOK/err.log last 15 lines: For my understanding this means already PM2_HOME not being correctly set prior to the child process exec call. So leaves the question to me how this can be lost after PM2 restarts the app. For sure this leads then also to not having that environment in child process exec at end. |
@vmarchaud |
@Papakai can you link back the commit / issue? this might impact others! Thanks for the investigation! |
There came different things together in this issue: we changed our deployment process in the way to provide the NODE_ENV environment some time ago and this dropped out other process.env vars. We haven't noticed about it as our webhooks stopped restarting themselves and kept using the working one in memory. It left us the impression that node.js changed its behavior, but I assume it did not. |
Expected behaviour
PM2_HOME being as set as provided through
pm2 startup -hp
flagActual behaviour
PM2_HOME corresponds to /etc/.pm2 in child process (exec) and thus leading to EACCES error (which we can see the pm2 logs of our webhook app). If you need these logs too, let me know.
Steps to reproduce
So basically everything worked with older versions of pm2 (2.0.16) which we have installed on our old server infrastructure. Node.js v4.6.1 was installed there and also debian 8. That's at least what has changed, not sure if it plays a role in this issue.
PM2_HOME is getting considered correctly everythere, but no longer in our Webhook.
All our pm2 apps are getting started under user node/group node. home directory is then /home/node.
Our webhook reacts on gitlab notifications which we parse and in case it matches our needs, we update our app(s) and do a pm2 restart. Our webhook is realized as a separate PM2 app. Here the config.
On the old servers, we have not set PM2_HOME explicitely. But the above home directory is getting used and everything worked fine (including the webhook). On the new servers, PM2_HOME was also not set correctly, but as the webhook had problems, we also tried pm2 startup -hp accordingly with no success. So basically our question/issue plays around how to set PM2_HOME correctly and why it behaves different (is a bug of the old version as it worked or a bug of the new version as it is no longer working).
So where is that PM2_HOME getting lost exactly? As said our webhook app executes some deploy/build script if some criteria matched in the gitlab notification request. How does that look like/work? The webhook executes a shell command with optional options using require('child_process').exec. See below. Looks like PM2_HOME or even the home directory itself is no longer available in that child process.
Maybe it is already very help to describe a best practise on how to set PM2_HOME, so that we can go step by step through it to identify whats going wrong.
WEBHOOK pm2.json:
deploy script example:
child process exec command/options example:
If you need further inputs or in case something is unclear, feel free to ask. TIA!
Software versions used
PM2 Log output
Use the command:
tail --lines 50 ~/.pm2/pm2.log
cf CONTRIBUTING.md for more informations
The text was updated successfully, but these errors were encountered: