Mindera / pm2-cookbook

Chef cookbook to install and manage PM2.
MIT License
23 stars 17 forks source link

added PM2_HOME env var to pm2 commands and reverted pm2 home env #11

Closed jarosser06 closed 9 years ago

jarosser06 commented 9 years ago

added PM2_HOME env var to pm2 commands and reverted pm2 home env variable

miguelcnf commented 9 years ago

Hey Jim, thanks for picking this up while I didn't have a chance to do it myself.

Couple of notes on the PR:

Besides that I'm wondering if we shouldn't always append .pm2 to the home directory - that's the default behaviour for pm2 when using the default user home - the benefit would be improved consistency - we'd just need to make sure that it was stated in the README.

For instance: If we have user nodeuser and set PM2_HOME to /home/nodeuser everything will be fine until someone logs into the box and runs pm2 status without setting the PM2_HOME env var - at that moment a new empty God Daemon will be created using /home/nodeuser/.pm2.

jarosser06 commented 9 years ago

So the only way I could get the command to work reliably is setting PM2_HOME before each command in previous versions ( I had patched the cookbook but forgot to make a PR), I haven't really taken the time to dig in and determine if this is still an issue tho. ATM it doesn't hurt anything but I can remove it if need be.

I don't think appending .pm2 does much since by default pm2 seems to use whatever directory you give it and create a .pm2 directory inside it. I think its better to leave that up to the discretion of the user than to assign that in the resource provider.

miguelcnf commented 9 years ago

I don't think appending .pm2 does much since by default pm2 seems to use whatever directory you give it and create a .pm2 directory inside it. I think its better to leave that up to the discretion of the user than to assign that in the resource provider.

This is not right afaics in v0.12.5 - PM2 creates all control files including the dump.pm2 (critical for reboots) directly in the PM2_HOME env var if set - it only creates a default .pm2 in the user home directory if the PM2_HOME variable isn't set. As I mentioned above I don't think this is really ideal.

I've went ahead and pushed b1b316b481a3305b3c23b41c183a4ddcb44a6134 to master which should do the same as this but appending the .pm2 directory to the home attribute if it doesn't exist - also added a bunch more tests to cover these scenarios.

I'm closing the PR - thanks tho and feel free to re-open this or open a new issue if you find something wrong with the implementation.