@@ 667-702 (lines=36) @@ | ||
664 | * @param array $backendOptions options for each backend |
|
665 | * @return string |
|
666 | */ |
|
667 | protected function _vcl_director($name, $backendOptions) { |
|
668 | $tpl = <<<EOS |
|
669 | director {{name}} round-robin { |
|
670 | {{backends}} |
|
671 | } |
|
672 | EOS; |
|
673 | if ('admin' == $name && 'yes_admin' == Mage::getStoreConfig('turpentine_vcl/backend/load_balancing')) { |
|
674 | $backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL, |
|
675 | Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes_admin')); |
|
676 | $probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url_admin'); |
|
677 | $prefix = 'admin'; |
|
678 | } else { |
|
679 | $backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL, |
|
680 | Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes')); |
|
681 | $probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url'); |
|
682 | if ('admin' == $name) { |
|
683 | $prefix = 'admin'; |
|
684 | } else { |
|
685 | $prefix = ''; |
|
686 | } |
|
687 | } |
|
688 | $backends = ''; |
|
689 | $number = 0; |
|
690 | foreach ($backendNodes as $backendNode) { |
|
691 | $parts = explode(':', $backendNode, 2); |
|
692 | $host = (empty($parts[0])) ? '127.0.0.1' : $parts[0]; |
|
693 | $port = (empty($parts[1])) ? '80' : $parts[1]; |
|
694 | $backends .= $this->_vcl_director_backend($host, $port, $prefix.$number, $probeUrl, $backendOptions); |
|
695 | $number++; |
|
696 | } |
|
697 | $vars = array( |
|
698 | 'name' => $name, |
|
699 | 'backends' => $backends |
|
700 | ); |
|
701 | return $this->_formatTemplate($tpl, $vars); |
|
702 | } |
|
703 | ||
704 | /** |
|
705 | * Format a VCL backend declaration to put inside director |
@@ 131-167 (lines=37) @@ | ||
128 | * @param array $backendOptions options for each backend |
|
129 | * @return string |
|
130 | */ |
|
131 | protected function _vcl_director($name, $backendOptions) { |
|
132 | $tpl = <<<EOS |
|
133 | {{backends}} |
|
134 | EOS; |
|
135 | if ('admin' == $name && 'yes_admin' == Mage::getStoreConfig('turpentine_vcl/backend/load_balancing')) { |
|
136 | $backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL, |
|
137 | Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes_admin')); |
|
138 | $probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url_admin'); |
|
139 | $prefix = 'admin'; |
|
140 | } else { |
|
141 | $backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL, |
|
142 | Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes')); |
|
143 | $probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url'); |
|
144 | ||
145 | if ('admin' == $name) { |
|
146 | $prefix = 'admin'; |
|
147 | } else { |
|
148 | $prefix = ''; |
|
149 | } |
|
150 | } |
|
151 | ||
152 | $backends = ''; |
|
153 | $number = 0; |
|
154 | foreach ($backendNodes as $backendNode) { |
|
155 | $parts = explode(':', $backendNode, 2); |
|
156 | $host = (empty($parts[0])) ? '127.0.0.1' : $parts[0]; |
|
157 | $port = (empty($parts[1])) ? '80' : $parts[1]; |
|
158 | $backends .= $this->_vcl_director_backend($host, $port, $prefix.$number, $probeUrl, $backendOptions); |
|
159 | ||
160 | $number++; |
|
161 | } |
|
162 | $vars = array( |
|
163 | 'name' => $name, |
|
164 | 'backends' => $backends |
|
165 | ); |
|
166 | return $this->_formatTemplate($tpl, $vars); |
|
167 | } |
|
168 | ||
169 | /** |
|
170 | * Format a VCL backend declaration to put inside director |