Skip to content
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

forever stop <pid> stops ALL processes (behaves like stopall) #659

Closed
et304383 opened this issue Dec 30, 2014 · 21 comments
Closed

forever stop <pid> stops ALL processes (behaves like stopall) #659

et304383 opened this issue Dec 30, 2014 · 21 comments

Comments

@et304383
Copy link

Easy to reproduce. Start two node services using forever. Try to stop one using the process ID. Forever stops ALL processes:

[root@ip-10-200-81-145 builds]# FOREVER_ROOT=/var/run/forever forever list
info:    Forever processes running
data:        uid  command script      forever pid   id logfile                               uptime      
data:    [0] Oquh node    app.js 3200 17625   17646    /var/log/forever/3200.log    0:0:0:34.622
data:    [1] hWkI node    app.js 3000 18068   18070    /var/log/forever/3000.log    0:0:0:18.858
data:    [2] mv1U node    app.js 3151 18482   18520    /var/log/forever/3151.log    0:0:0:6.273 
[root@ip-10-200-81-145 builds]# FOREVER_ROOT=/var/run/forever forever stop 18520
info:    Forever stopped process:
    uid  command script      forever pid   id logfile                               uptime
[0] Oquh node    app.js 3200 17625   17646    /var/log/forever/3200.log    0:0:1:50.470
[1] hWkI node    app.js 3000 18068   18070    /var/log/forever/3000.log    0:0:1:34.707
[2] mv1U node    app.js 3151 18482   18520    /var/log/forever/3151.log    0:0:1:22.122
[root@ip-10-200-81-145 builds]# FOREVER_ROOT=/var/run/forever forever list
info:    No forever processes running
[root@ip-10-200-81-145 builds]#
@et304383
Copy link
Author

Turns out it's worse than I thought. It appears to be doing some kind of default behaviour when it can't find the application to terminate.

[root@ip-10-37-50-28 forever]# FOREVER_ROOT=/var/run/forever forever list
^[[Ainfo:    Forever processes running
data:        uid  command script       forever pid   id logfile                            uptime
data:    [0] NSjx node    init.js 3002 13083   13087    /var/log/node/3002.log 0:0:0:3.909
data:    [1] 6j0I node    init.js 3003 13093   13095    /var/log/node/3003.log 0:0:0:2.732
[root@ip-10-37-50-28 forever]# FOREVER_ROOT=/var/run/forever forever stop 9823098409283904
info:    Forever stopped process:
    uid  command script       forever pid   id logfile                            uptime
[0] NSjx node    init.js 3002 13083   13087    /var/log/node/3002.log 0:0:0:6.252
[1] 6j0I node    init.js 3003 13093   13095    /var/log/node/3003.log 0:0:0:5.74
[root@ip-10-37-50-28 forever]# FOREVER_ROOT=/var/run/forever forever list
info:    No forever processes running

It still terminates all forever processes.

Edit: disregard anything I said about running as a different user - this behaviour is the same when root runs everything.

@et304383
Copy link
Author

Using "uid" to stop seems to still work.

@derEremit
Copy link

Just updated and killed a bunch of live processes
Seriously critical issue!!!!!
forever v 14.0

@et304383
Copy link
Author

et304383 commented Jan 2, 2015

How could this be missed? Do you not have regression tests? This is a critical bug.

@jcrugzz
Copy link
Contributor

jcrugzz commented Jan 2, 2015

Very odd indeed, this should not have gotten past tests. @Tjatse this seems to be related to your work around stop, could you look into this?

@Tjatse
Copy link
Contributor

Tjatse commented Jan 3, 2015

Sorry about the confusions, the test suit does not coverage this, try to manually update your local codes like below:
https://github.com/foreverjs/forever/blob/master/lib/forever.js#L232-L236

      procs = forever.findById(target, processes)
        || forever.findByIndex(target, processes)
        || forever.findByUid(target, processes)
        || forever.findByPid(target, processes);

Actually, this is an unfinished work, there still have too much PRs from my repository, but have no time to wait for approving.

Any way, glad to help solve this, and again, sorry for the bug, guys!
My forked repository has been deleted, so, anyone could help to send a PR will be appreciated.

@indexzero
Copy link
Member

Hah. Sorry you're not sorry? We'll figure it out. So we should expect more bugs from your other PR?

@Tjatse
Copy link
Contributor

Tjatse commented Jan 3, 2015

Weird tone :(
This is totally unexpected, I just wanna to help to make this tool better, if you think I am doing a wrong thing, and curse me for that, I think I deserved.

I've figure it out, and always glad to do that. I still do the jobs but not only say Sorry, right?

@derEremit
Copy link

No matter what happens with this issue, but someone should immediately pull the release 0.14 from npm (if that's possible) before more people upgrade and kill all their running processes!!!!

@jcrugzz
Copy link
Contributor

jcrugzz commented Jan 3, 2015

@Tjatse I don't believe @indexzero understands your tone here either. It seems you submitted unfinished work that was finished in a later pull-request. This creates mismatched expectations of what a patch consists of if it was expected to be unfinished. What he is trying to build here is trust. He likes that you are enthusiastic about helping but patience and attention to detail are crucial in a project that has many people who depend on it. A thorough review process is required and when there is not time for that, pull-requests can sit for a while. I understand this is difficult as the contributor as you want to help and see your patches land, but trust needs to be built in the beginning. Things do not always operate at a rapid pace, and that can be for good reason. If trust can be earned through the learning process that happens through open source contribution, things can move faster, but its obviously not at that point yet.

@derEremit It has been unpublished

@rubaboo
Copy link

rubaboo commented Apr 15, 2015

Somehow this re-surfaced, this time only when pid is zero.

@sharjeel-ahmed
Copy link

When pid is zero it terminates all processes, a serious bug, i ended up terminating all processes.

@softius
Copy link

softius commented Oct 27, 2015

It appears that the commands stop 0 and restart 0 function exactly like stopall and restartall.

@sharjeel-ahmed
Copy link

The problem has not gone away yet.

@bdmayes
Copy link

bdmayes commented Nov 10, 2015

I can confirm that I am seeing the same behavior. Executing forever stop 0 results in all running processes being terminated.

@rodikh
Copy link

rodikh commented Nov 26, 2015

+1
Here too, when running forever stop 0 all processes stop.
forever version: v0.15.1

@JamieMcNaught
Copy link
Contributor

This has been fixed in the main codebase (see pull request #756) but there hasn't been a release since then. My current deployment system is using a custom build including this fix which we deploy via:

npm install -g git://github.com/JamieMcNaught/forever.git

You can do similar with the current dev branch of forever using something like:

npm install -g git://github.com/foreverjs/forever.git

However with both solutions, bear in mind that either of these branches could be horribly broken when compared to a proper release (albeit my branch has been used in production for a while now and I don't intend to make any changes to it).

@stevenmyhre
Copy link

+1 Still seeing this,

forever stop 0 is stopping all processes

any updates?

@JamieMcNaught
Copy link
Contributor

@stevenmyhre - have you tried with of the git repo's mentioned in my previous comment (Dec 02 2015)? I've been using this successfully for a number of projects.

@stevenmyhre
Copy link

No, I'll wait for the official release

@indexzero
Copy link
Member

This was fixed in 0.15.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests