Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 390507 - net-proxy/haproxy - init script start-stop-daemon not handling multiple pids - only stopping the first process listed.
Summary: net-proxy/haproxy - init script start-stop-daemon not handling multiple pids ...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Christian Ruppert (idl0r)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-14 11:12 UTC by Simon Alman
Modified: 2012-05-18 20:54 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Alman 2011-11-14 11:12:16 UTC
https://forums.gentoo.org/viewtopic-p-6871902.html#6871902

I'm running haproxy with "nbproc 2" i.e. two processes (one per core), unfortunately the init script is only killing one process (the first one it comes to in the pid file) when I run stop.

I've read the man page for the start-stop-daemon and it implies it can handle pid(s). Any suggestions on things I can try to solve this ?

---------------------------------------------------------------------------
Code:
nostromo ~ # cat /var/run/haproxy.pid
27172
27173

---------------------------------------------------------------------------
Code:
nostromo ~ # /etc/init.d/haproxy -v stop
haproxy                  | * Caching service dependencies ...
[ ok ]
haproxy                  | * Stopping haproxy ...
haproxy                  | * Will stop PID in pidfile
`/var/run/haproxy.pid'
haproxy                  | * Sending signal 15 to PID 27172 ...
---------------------------------------------------------------------------
Code:

nostromo ~ # ps wax | grep haproxy
16230 pts/0    S+     0:00 grep --colour=auto haproxy
27173 ?        Ss     0:00 /usr/bin/haproxy -D -p /var/run/haproxy.pid -f /etc/haproxy.cfg 
---------------------------------------------------------------------------

Changing to using the process name instead of a pid file seems to be one way to go:

Code:
        #start-stop-daemon --stop --pidfile "${PIDFILE}"
        start-stop-daemon --stop --name "haproxy" 

Reproducible: Always

Steps to Reproduce:
1. Add "nbproc 2" under the global block in /etc/haproxy.cfg
2. Start up haproxy and check that you have two haproxy processes running
3. /etc/init.d/haproxy stop and you should still have one process running
Actual Results:  
One process is left running

Expected Results:  
All processes should be stopped
Comment 1 William Hubbs gentoo-dev 2011-11-15 18:26:52 UTC
According to the FHS [1], the pid files in /var/run should only contain
one pid per file, so we should not support multiple pids.

[1] http://proton.pathname.com/fhs/pub/fhs-2.3.html#VARRUNRUNTIMEVARIABLEDATA
Comment 2 Simon Alman 2011-11-16 08:36:48 UTC
Would it be an option to store the pid's in seperate files i.e. /var/run/haproxy.pid.<pid id>  and then do a check for all files starting with haproxy.pid and pull their details that way ? 

I'm sure there must be other daemons that use multiple pid's but I've not found one yet to see how they handle this.

Or we could just use the -n haproxy method which is what I'm doing atm. 

Wiser folks than me will hopefully know how other projects handle this situation.
Comment 3 Christian Ruppert (idl0r) gentoo-dev 2011-11-16 16:55:12 UTC
Usually the parent should kill all childs. So only one pid in the pid file should be needed.
Using -n <name> would *probably* also kill possible other daemons. That has to be tested first.
Comment 4 Christian Ruppert (idl0r) gentoo-dev 2012-02-28 06:06:46 UTC
This should be fixed by upstream instead. The parent should kill all childs and only one pid should be written into a pidfile.
So I guess I'll close this bug as WONTFIX or UPSTREAM soon.

@robbat, @craig:
What do you think?
Comment 5 Christian Ruppert (idl0r) gentoo-dev 2012-05-18 20:54:43 UTC
As I said prior, closing as WONTFIX.