From 37f8d11960f14da4a8aeca7825e7bb27b48ee7a0 Mon Sep 17 00:00:00 2001 From: marcelloc Date: Thu, 4 Aug 2011 04:24:57 -0300 Subject: Error Handling Improvements, faster update process and bug fixes --- config/varnish64/varnish.inc | 81 ++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 40 deletions(-) (limited to 'config/varnish64') diff --git a/config/varnish64/varnish.inc b/config/varnish64/varnish.inc index 76f61ec4..f842348f 100644 --- a/config/varnish64/varnish.inc +++ b/config/varnish64/varnish.inc @@ -84,25 +84,6 @@ function varnish_start() { mwexec("/usr/local/etc/rc.d/varnish.sh"); } -/* Return true if a backend is in use */ -function is_varnish_backend_in_use($backendname) { - global $config, $g; - if($config['installedpackages']['varnishlbdirectors']['config'] != "") - foreach($config['installedpackages']['varnishlbdirectors']['config'] as $url) - if($url['row']) - foreach($url['row'] as $urlmapping) - if($urlmapping['backendname'] == $backendname) - return true; - if($config['installedpackages']['varnishbackends']['config'] != "") - foreach($config['installedpackages']['varnishbackends']['config'] as $backend) - if($backend['backendname'] == $backendname) - if($backend['row']) - foreach($backend['row'] as $row) - if($row['urlmapping']) - return true; - return false; -} - /* Build the URL mappings logic VCL config txt */ function varnish_get_url_mappings_txt() { global $g, $config, $urlmappings; @@ -192,6 +173,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ sync_package_varnish(); ?> ENDOFF + /usr/local/sbin/varnishd \ {$listeningport} \ -f /var/etc/default.vcl \ @@ -206,7 +188,7 @@ EOF; function get_backend_config_txt() { global $config, $g; - $backends_used = array(); + $backends=""; if($config['installedpackages']['varnishbackends']['config'] != "") { foreach($config['installedpackages']['varnishbackends']['config'] as $backend) { if($backend['connect_timeout']) @@ -214,17 +196,25 @@ function get_backend_config_txt() { else $connect_timeout = "25s"; if($backend['port']) - $connect_timeout = $backend['port'] . "s"; + $connect_port = $backend['port']; else - $connect_timeout = "80s"; + $connect_port = "80"; if($backend['first_byte_timeout']) $first_byte_timeout = $backend['first_byte_timeout'] . "s"; else $first_byte_timeout = "300s"; if($backend['probe_url']) - $probe_url = $backend['probe_url']; + if (preg_match("@^(http)://(.*)(/.*|/)$@",$backend['probe_url'],$matches)){ + $probe_url=".request =\n"; + $probe_url.="\t\t\t".'"GET '.$matches[3].' HTTP/1.1"'."\n"; + $probe_url.="\t\t\t".'"Host: '.$matches[2].'"'."\n"; + $probe_url.="\t\t\t".'"Connection: Close";'; + } + else{ + $probe_url = '.url = "'.$backend['probe_url'].'";'; + } else - $probe_url = "/"; + $probe_url ='.url = "/";'; if($backend['probe_interval']) $probe_interval = $backend['probe_interval'] . "s"; else @@ -241,16 +231,16 @@ function get_backend_config_txt() { $probe_threshold = $backend['probe_threshold']; else $probe_threshold = "5"; - if(is_varnish_backend_in_use($backend['backendname'])) - if(!in_array($backend['backendname'], $backends_used)) - $backends .= <<