HAProxy fails to start at boot time
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
haproxy (Ubuntu) |
Expired
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: haproxy
I've got haproxy installed and configured on one of my servers. In the first 'listen' section of the config file, it binds to a number of aliased IP addresses. While I can start the service fine from the login prompt, it would not start at boot time, instead it showed the following in /var/log/boot.log
* Starting haproxy haproxy [ALERT] 346/160552 (927) : Starting proxy haproxy: cannot bind socket
[ALERT] 346/160552 (927) : Starting proxy haproxy: cannot bind socket
[ALERT] 346/160552 (927) : Starting proxy haproxy: cannot bind socket
[ALERT] 346/160552 (927) : Starting proxy haproxy: cannot bind socket
[ALERT] 346/160552 (927) : Starting proxy haproxy: cannot bind socket
[ALERT] 346/160552 (927) : Starting proxy haproxy: cannot bind socket
[ALERT] 346/160552 (927) : Starting proxy haproxy: cannot bind socket
On inspection the problem seems to come down to the lack of and specified start/stop numbers in the sysV init scripts, so it defaults to S20/K20 for everything. While the correct solution is to write an upstart script for haproxy, in the mean time, it should be set, so that the start number is higher than 35 (which seems to be the number /etc/init.
Changing the startup number to 35 seems to fix it, but I think 36 would be safer (the old number for networking was 35, so best make it start after that).
This fixed the problem, on my server:-
update-rc.d -f haproxy remove
update-rc.d haproxy start 36 2 3 4 5 . stop 20 0 1 6 .
Just a quick follow up, that didn't fix it. It went away for a bit, then magically came back. The solution seemed to be to add networking to init.d startup directories before haproxy:-
update-rc.d networking start 35 2 3 4 5 .
Like I said, the solution is probably to create a proper upstart script