aboutsummaryrefslogtreecommitdiffstats
path: root/config/haproxy-devel/haproxy.inc
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2013-05-30 00:25:43 -0700
committerErmal Luçi <eri@pfsense.org>2013-05-30 00:25:43 -0700
commitdcccb98d5d9dfbf3f3e9a8a2272324dbc3e67ed8 (patch)
treef5df55c21715cc9e3437e3929e011f65a9f38b38 /config/haproxy-devel/haproxy.inc
parent917bec0541467546dec54baba72ae99077823736 (diff)
parent0486d32f0b5f4d514f02f68c33f22f0864f20ac1 (diff)
downloadpfsense-packages-dcccb98d5d9dfbf3f3e9a8a2272324dbc3e67ed8.tar.gz
pfsense-packages-dcccb98d5d9dfbf3f3e9a8a2272324dbc3e67ed8.tar.bz2
pfsense-packages-dcccb98d5d9dfbf3f3e9a8a2272324dbc3e67ed8.zip
Merge pull request #453 from PiBa-NL/haproxy-devel-2.1
haproxy-devel, fix required fields a shared-backend, optional Force immediate stop of old process on reload, fix show memory usage.
Diffstat (limited to 'config/haproxy-devel/haproxy.inc')
-rw-r--r--config/haproxy-devel/haproxy.inc35
1 files changed, 27 insertions, 8 deletions
diff --git a/config/haproxy-devel/haproxy.inc b/config/haproxy-devel/haproxy.inc
index 735ab196..66bcf81f 100644
--- a/config/haproxy-devel/haproxy.inc
+++ b/config/haproxy-devel/haproxy.inc
@@ -867,10 +867,12 @@ function haproxy_load_modules() {
function use_transparent_clientip_proxying() {
global $config;
$a_backends = &$config['installedpackages']['haproxy']['ha_pools']['item'];
- foreach ($a_backends as $backend) {
- if ($backend["transparent_clientip"] == 'yes') {
- return true;
- break;
+ if (is_array($a_backends)) {
+ foreach ($a_backends as $backend) {
+ if ($backend["transparent_clientip"] == 'yes') {
+ return true;
+ break;
+ }
}
}
return false;
@@ -939,7 +941,8 @@ function haproxy_check_run($reload) {
if ($status != "MASTER") {
if (haproxy_is_running()) {
log_error("Stopping haproxy on CARP backup.");
- exec("/bin/pkill -F /var/run/haproxy.pid haproxy");
+ //exec("/bin/pkill -F /var/run/haproxy.pid haproxy");//doesnt work for multiple pid's in a pidfile
+ haproxy_kill();
}
return (0);
} else if (haproxy_is_running() && $reload == 0) {
@@ -951,7 +954,11 @@ function haproxy_check_run($reload) {
return (0);
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` 2>&1", $output, $errcode);
+ if (isset($a_global['terminate_on_reload']))
+ $sf_st = "-st";//terminate old process as soon as the new process is listening
+ else
+ $sf_st = "-sf";//finish serving existing connections exit when done, and the new process is listening
+ exec("/usr/local/sbin/haproxy -f /var/etc/haproxy.cfg -p /var/run/haproxy.pid $sf_st `cat /var/run/haproxy.pid` 2>&1", $output, $errcode);
} else {
exec("/usr/local/sbin/haproxy -f /var/etc/haproxy.cfg -p /var/run/haproxy.pid -D 2>&1", $output, $errcode);
}
@@ -960,11 +967,23 @@ function haproxy_check_run($reload) {
return ($errcode);
} else {
if ($reload && haproxy_is_running()) {
- exec("/bin/pkill -F /var/run/haproxy.pid haproxy");
+ //exec("/bin/pkill -F /var/run/haproxy.pid haproxy");//doesnt work for multiple pid's in a pidfile
+ haproxy_kill();
}
return (0);
}
-
+}
+
+function haproxy_kill($killimmediately = true) {
+ if ($killimmediately)
+ $signal = "KILL"; // stop now
+ else
+ $signal = "USR1"; // stop when all connections are closed
+ killprocesses("haproxy", "/var/run/haproxy.pid", $signal);
+}
+
+function killprocesses($processname, $pidfile, $signal = "KILL") {
+ exec("kill -$signal `pgrep -x $processname | grep -w -f $pidfile`");
}
function haproxy_do_xmlrpc_sync($sync_to_ip, $password) {