diff options
author | thompsa <andy@fud.org.nz> | 2010-03-12 15:50:23 +1300 |
---|---|---|
committer | thompsa <andy@fud.org.nz> | 2010-03-12 15:50:23 +1300 |
commit | c68429d0148425c085cb16ab33bb6b054fa9a558 (patch) | |
tree | 8abb4f86ccfc481153e0e2c47cac6aa8dcf0890d | |
parent | 9cf42f047c49d03b518f17b0688ed9c46fd6ec63 (diff) | |
download | pfsense-packages-c68429d0148425c085cb16ab33bb6b054fa9a558.tar.gz pfsense-packages-c68429d0148425c085cb16ab33bb6b054fa9a558.tar.bz2 pfsense-packages-c68429d0148425c085cb16ab33bb6b054fa9a558.zip |
Fix broken devd script and make local haproxy_is_running() function
since is_process_running() is broken as we are called through the rc.d
script by the same name.
-rw-r--r-- | config/haproxy-dev/haproxy.inc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 10d7c24b..dc9b8983 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -138,16 +138,17 @@ EOD; $devd = <<<EOD notify 0 { match "system" "IFNET"; - match "subsystem "carp[0-9]+"; + match "subsystem" "carp[0-9]+"; match "type" "LINK_UP"; action "/usr/local/etc/rc.d/haproxy.sh check"; }; notify 0 { match "system" "IFNET"; - match "subsystem "carp[0-9]+"; + match "subsystem" "carp[0-9]+"; match "type" "LINK_DOWN"; action "/usr/local/etc/rc.d/haproxy.sh check"; }; + EOD; exec("mkdir -p /etc/devd"); $fd = fopen("/etc/devd/haproxy.conf", "w"); @@ -542,6 +543,11 @@ function haproxy_writeconf() { } } +function haproxy_is_running() { + $running = (shell_exec("/bin/pgrep -x haproxy") != ''); + return $running; +} + function haproxy_check_run($reload) { global $config, $g; @@ -553,21 +559,25 @@ function haproxy_check_run($reload) { if (isset($a_global['carpdev'])) { $status = get_carp_interface_status($a_global['carpdev']); if ($status != "MASTER") { - exec("/bin/pkill -F /var/run/haproxy.pid haproxy"); + if (haproxy_is_running()) { + log_error("Stopping haproxy on CARP backup."); + exec("/bin/pkill -F /var/run/haproxy.pid haproxy"); + } + return (0); + } else if (haproxy_is_running() && $reload == 0) { return (0); - } else if (is_process_running('haproxy') && $reload == 0) { - return (0); } + log_error("Starting haproxy on CARP master."); /* fallthrough */ } - if (is_process_running('haproxy')) { + if (haproxy_is_running()) { exec("/usr/local/sbin/haproxy -f /var/etc/haproxy.cfg -p /var/run/haproxy.pid -st `cat /var/run/haproxy.pid`"); } else { exec("/usr/local/sbin/haproxy -f /var/etc/haproxy.cfg -p /var/run/haproxy.pid -D"); } return (0); } else { - if ($reload && is_process_running('haproxy')) { + if ($reload && haproxy_is_running()) { exec("/bin/pkill -F /var/run/haproxy.pid haproxy"); } return (1); |