-
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 fails to return correctly in ansible #88
Comments
This is strange, I do the classical |
I'm invoking pm2 through SSH on my CI server (via Atlassian Bamboo) and are stuck in a similar situation. My call to pm2 is |
i'm also invoking pm2 via ssh this won't return from the ssh command - but if i run it locally it returns with an exit code of 0 ($?) |
I've run into this bug too. Ansible hangs when it reaches pm2 start even though the command has been executed on the server. |
isn't it an Ansible bug? |
It seems more a factor of the text output from pm2. |
I think this is related to the bug described in #235. I used Ansible's async fire and forget to start pm2 before running any other commands.
|
|
Same is true for Salt stack. First time I encounter bug of this kind with Salt.
|
Same here with Ansible. Hangs on "start", even when wrapped in a Bash script that exits. Tried "pm2 kill" beforehand to try and restart the whole process, but no luck. |
usually "start" hangs when the process is already running or when you try to start it from a different directory that is messing up your lib imports. This is what I use successfully:
|
to install PM2 I use:
and
|
👍 Closing for now, feel free to re-open. |
Thank you for the tips @luckychild305 I'll give it a go :) |
I have the same problem with running any "pm2" command via SaltStack. After struggling with it for some time, I finally found a workaround:
Even though the salt-minion process runs as root, without that explicit "- user: root" in there, the command will hang. This can be a highstate or even a cmd.run for the specific state that executes pm2 commands. Any pm2 command would hang: ping, startup, show, etc... I theorize that having the -user option in the state causes salt to spawn a new shell and that shell is sufficiently different than the one running the command by default. (shrug) |
@sjwoodr Confirmed (on pm2 v0.14.7 and salt v2015.5.3) that pm2 now works properly when invoked from salt. Thanks! |
Big thanks @sjwoodr for sharing this! |
Awesome. Glad its working for you guys! |
The success exit status is 0. |
Oh, this one is still not fixed? :D Essentially, the correct should be |
When pm2 commands are run through ansible they operate correctly but fail to return in a way that ansible recognises causing ansible to be stuck at that location waiting for a correct exit.
For example a command like
$ pm2 start pm2-start.json
will run the script but hang afterwards. If you kill that script in a different terminal session the still running script in the other session will finally continue. You can also work around the problem by attaching >& /dev/null to the end of the script so the ansible command might end up looking like this.
shell: pm2 start pm2-start.json >& /dev/null chdir=~/ executable=/bin/bash
The text was updated successfully, but these errors were encountered: