From 7e040dd03c3aaa76f594a4447c42f7a8da54dad3 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Mon, 17 Oct 2011 11:21:28 -0400
Subject: [PATCH] - Server Config > Rescue tab: Replaced Apache monitoring with HTTPD monitoring to include nginx.

---
 interface/web/admin/lib/lang/de_server_config.lng           |   10 +++++-----
 interface/web/admin/templates/server_config_rescue_edit.htm |    4 ++--
 server/mods-available/rescue_core_module.inc.php            |   32 +++++++++++++++++++-------------
 interface/web/admin/lib/lang/en_server_config.lng           |    4 ++--
 install/tpl/server.ini.master                               |    2 +-
 interface/web/admin/form/server_config.tform.php            |    2 +-
 6 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master
index 469823c..cf4247c 100644
--- a/install/tpl/server.ini.master
+++ b/install/tpl/server.ini.master
@@ -102,7 +102,7 @@
 
 [rescue]
 try_rescue=n
-do_not_try_rescue_apache=n
+do_not_try_rescue_httpd=n
 do_not_try_rescue_mysql=n
 do_not_try_rescue_mail=n
 
diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php
index fe2a1c6..5c6c12d 100644
--- a/interface/web/admin/form/server_config.tform.php
+++ b/interface/web/admin/form/server_config.tform.php
@@ -1045,7 +1045,7 @@
 			'default' => 'n',
 			'value' => array(0 => 'n', 1 => 'y')
 		),
-		'do_not_try_rescue_apache' => array(
+		'do_not_try_rescue_httpd' => array(
 			'datatype' => 'VARCHAR',
 			'formtype' => 'CHECKBOX',
 			'default' => 'n',
diff --git a/interface/web/admin/lib/lang/de_server_config.lng b/interface/web/admin/lib/lang/de_server_config.lng
index 55552b0..71bc79f 100644
--- a/interface/web/admin/lib/lang/de_server_config.lng
+++ b/interface/web/admin/lib/lang/de_server_config.lng
@@ -143,10 +143,10 @@
 $wb['php_fpm_socket_dir_error_empty'] = 'PHP-FPM Socket-Verzeichnis ist leer.';
 $wb['fastcgi_config_syntax_txt'] = 'FastCGI config syntax';
 $wb['backup_dir_ftpread_txt'] = 'Backup dir. readable for website FTP users.';
-$wb['try_rescue_txt'] = 'Enable service monitoring and restart on failure';
-$wb['do_not_try_rescue_apache_txt'] = 'Disable apache monitoring';
-$wb['do_not_try_rescue_mysql_txt'] = 'Disable MySQL monitoring';
-$wb['do_not_try_rescue_mail_txt'] = 'Disable Email monitoring';
-$wb['rescue_description_txt'] = '<b>Information:</b> If you want to shut down mysql you have to select the Disable MySQL monitor checkbox and then wait 2-3 minutes.<br>if you do not wait 2-3 minutes, rescue will try to restart mysql!';
+$wb['try_rescue_txt'] = 'Aktiviere Service Monitoring und Neustart bei Unerreichbarkeit';
+$wb['do_not_try_rescue_httpd_txt'] = 'Deaktiviere HTTPD Monitoring';
+$wb['do_not_try_rescue_mysql_txt'] = 'Deaktiviere MySQL Monitoring';
+$wb['do_not_try_rescue_mail_txt'] = 'Deaktiviere Email Monitoring';
+$wb['rescue_description_txt'] = '<b>Information:</b> Falls Sie MySQL stoppen m&ouml;chten, w&auml;hlen Sie die &quot;Deaktiviere MySQL Monitoring&quot; Checkbox und warten Sie 2-3 Minuten.<br>Falls Sie nicht 2-3 Minuten warten, wird Rescue versuchen, MySQL neu zu starten!';
 $wb['enable_sni_txt'] = 'Enable SNI';
 ?>
diff --git a/interface/web/admin/lib/lang/en_server_config.lng b/interface/web/admin/lib/lang/en_server_config.lng
index ec91e01..6b5b841 100644
--- a/interface/web/admin/lib/lang/en_server_config.lng
+++ b/interface/web/admin/lib/lang/en_server_config.lng
@@ -144,10 +144,10 @@
 $wb["php_fpm_socket_dir_txt"] = 'PHP-FPM socket directory';
 $wb["php_fpm_socket_dir_error_empty"] = 'PHP-FPM socket directory is empty.';
 $wb["try_rescue_txt"] = 'Enable service monitoring and restart on failure';
-$wb["do_not_try_rescue_apache_txt"] = 'Disable apache monitoring';
+$wb["do_not_try_rescue_httpd_txt"] = 'Disable HTTPD monitoring';
 $wb["do_not_try_rescue_mysql_txt"] = 'Disable MySQL monitoring';
 $wb["do_not_try_rescue_mail_txt"] = 'Disable Email monitoring';
-$wb["rescue_description_txt"] = '<b>Information:</b> If you want to shut down mysql you have to select the "Disable MySQL monitor" checkbox and then wait 2-3 minutes.<br>if you do not wait 2-3 minutes, rescue will try to restart mysql!';
+$wb["rescue_description_txt"] = '<b>Information:</b> If you want to shut down mysql you have to select the "Disable MySQL monitor" checkbox and then wait 2-3 minutes.<br>If you do not wait 2-3 minutes, rescue will try to restart mysql!';
 $wb["enable_sni_txt"] = 'Enable SNI';
 
 ?>
\ No newline at end of file
diff --git a/interface/web/admin/templates/server_config_rescue_edit.htm b/interface/web/admin/templates/server_config_rescue_edit.htm
index 3aa9bf6..99cbf79 100644
--- a/interface/web/admin/templates/server_config_rescue_edit.htm
+++ b/interface/web/admin/templates/server_config_rescue_edit.htm
@@ -12,9 +12,9 @@
 					</div>
 			</div>
       <div class="ctrlHolder">
-				<p class="label" style="width:300px">{tmpl_var name='do_not_try_rescue_apache_txt'}</p>
+				<p class="label" style="width:300px">{tmpl_var name='do_not_try_rescue_httpd_txt'}</p>
 					<div class="multiField" style="width:100px">
-						{tmpl_var name='do_not_try_rescue_apache'}
+						{tmpl_var name='do_not_try_rescue_httpd'}
 					</div>
 			</div>
       <div class="ctrlHolder">
diff --git a/server/mods-available/rescue_core_module.inc.php b/server/mods-available/rescue_core_module.inc.php
index f1c34ca..49012d5 100644
--- a/server/mods-available/rescue_core_module.inc.php
+++ b/server/mods-available/rescue_core_module.inc.php
@@ -89,14 +89,14 @@
 		$this->_rescueData = $this->_getRescueData();
 		
 		/*
-		 * rescue mysql if needed (maybe apache depends on mysql, so try this first!)
+		 * rescue mysql if needed (maybe httpd depends on mysql, so try this first!)
 		 */
 		$this->_rescueMySql();
 		
 		/*
-		 * rescue apache if needed
+		 * rescue httpd if needed
 		 */
-		$this->_rescueApache();
+		$this->_rescueHttpd();
 		
 		/*
 		 * The last step is to save the rescue-data
@@ -218,15 +218,15 @@
 	}
 
 	/**
-	 * restarts apache, if needed
+	 * restarts httpd, if needed
 	 */
-	private function _rescueApache(){
+	private function _rescueHttpd(){
 		global $app, $conf;
 		
 		/*
-		 * do nothing, if it is not allowed to rescue apache
+		 * do nothing, if it is not allowed to rescue httpd
 		 */
-		if ((isset($conf['serverconfig']['rescue']['do_not_try_rescue_apache']) && ($conf['serverconfig']['rescue']['do_not_try_rescue_apache']) == 'y')){
+		if ((isset($conf['serverconfig']['rescue']['do_not_try_rescue_httpd']) && ($conf['serverconfig']['rescue']['do_not_try_rescue_httpd']) == 'y')){
 			return;
 		}
 		
@@ -267,17 +267,23 @@
 		
 		/* if 5 times will not work, we have to give up... */
 		if ($tryCount > 5){
-			$app->log('Apache is down! Rescue will not help!', LOGLEVEL_ERROR);
+			$app->log('httpd is down! Rescue will not help!', LOGLEVEL_ERROR);
 			return;
 		}
 		
 		
-		$app->log('Apache is down! Try rescue apache (try:' . $tryCount . ')...', LOGLEVEL_WARN);
-
-		if(is_file($conf['init_scripts'] . '/' . 'httpd')) {
-			$daemon = 'httpd';
+		$app->log('httpd is down! Try rescue httpd (try:' . $tryCount . ')...', LOGLEVEL_WARN);
+		
+		if($conf['serverconfig']['web']['server_type'] == 'nginx'){
+			$daemon = 'nginx';
 		} else {
-			$daemon = 'apache2';
+			if(is_file($conf['init_scripts'] . '/' . 'httpd')) {
+				$daemon = 'httpd';
+			} elseif(is_file($conf['init_scripts'] . '/' . 'httpd2')){
+				$daemon = 'httpd2';
+			} else {
+				$daemon = 'apache2';
+			}
 		}
 		
 		$this->_rescueDaemon($daemon);

--
Gitblit v1.9.1