-
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 restart does not honor args from process start #3085
Comments
Here's a ready unit test showing the bug ^^ # setup test files
cat <<EOF > test2.js
var child_process = require('child_process');
setInterval(() => {}, 1000)
EOF
cat <<EOF > test1.js
var child_process = require('child_process');
child_process.spawn('sh', ['-c', 'echo hello; sleep 100'], {detached:true})
setInterval(() => {}, 1000)
console.log("spawned!!");
EOF
# First test with --no-treekill
echo Testing with --no-treekill
kill -9 `pgrep -f hello`&>/dev/null;
pm2 delete test.js&>/dev/null;
cp test1.js test.js;
pm2 start --no-treekill test.js&>/dev/null;
sleep 3
ps aux | grep hello | grep -v grep || echo "Expected process not found";
cp test2.js test.js;
pm2 restart --no-treekill test.js&>/dev/null;
sleep 5;
ps aux | grep hello | grep -v grep && echo "TEST OK" || echo "TEST FAIL"
echo Testing WITHOUT --no-treekill
kill -9 `pgrep -f hello`&>/dev/null;
pm2 delete test.js&>/dev/null;
cp test1.js test.js;
pm2 start --no-treekill test.js&>/dev/null;
sleep 3
ps aux | grep hello | grep -v grep || echo "Expected process not found";
cp test2.js test.js;
pm2 restart test.js&>/dev/null;
sleep 5;
ps aux | grep hello | grep -v grep && echo"TEST OK" || echo "TEST FAIL" root@x ~ # bash bug.sh
Testing with --no-treekill
root 26668 0.0 0.0 4508 784 ? Ss 02:04 0:00 sh -c echo hello; sleep 100
root 26668 0.0 0.0 4508 784 ? Ss 02:04 0:00 sh -c echo hello; sleep 100
TEST OK
Testing WITHOUT --no-treekill
root 26732 0.0 0.0 4508 796 ? Ss 02:04 0:00 sh -c echo hello; sleep 100
TEST FAIL |
I can see some code that's supposed to restore the 'env' during restart/reload so I am not sure why it doesnt work i.e. Line 341 in fd1f52d
https://github.com/Unitech/pm2/blob/master/lib/God/Reload.js#L117 |
thanks for the extensive report, bug confirmed looking to it |
fixed, you can try it now:
|
Thanks!! Happy to see it fixed :) |
@Unitech when can you release? :) |
Fixed on recently published pm2 (2.7.0): $ npm install pm2@latest -g
$ pm2 update Let me know if there is any issue |
I'm still observing this issue in v3.2.2 |
@Flicksie I wonder if you can reproduce with my unit test? But maybe ecosystem files are working differently and need a seperate fix... |
Your issue may already be reported!
Please search on the issue tracker before creating one.
What's going wrong?
So, I start my app either via
$ pm2 start --no-treekill myappbin
$ pm2 start myapp.json
with json having {treekill: false} inside.
I expect $ pm2 restart myapp to honor no-treekill the way it was declared at start.
But it's ignored.
So every pm2 restart brings a total disaster to my app killing all the detached childs.
What works is
$ pm2 restart --no-treekill myapp
How could we reproduce this issue?
Supporting information
Please run the following command (available on PM2 >= 2.6)
The text was updated successfully, but these errors were encountered: