From f7ec00b2f8ba3efc5bdeacef9c813f8a826ae3be Mon Sep 17 00:00:00 2001
From: Patrick Anders <p.anders@timmehosting.de>
Date: Wed, 10 Dec 2014 08:44:26 -0500
Subject: [PATCH] add Spdy option - http://en.wikipedia.org/wiki/SPDY

---
 server/mods-available/rescue_core_module.inc.php |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/server/mods-available/rescue_core_module.inc.php b/server/mods-available/rescue_core_module.inc.php
index 050d32f..5698273 100644
--- a/server/mods-available/rescue_core_module.inc.php
+++ b/server/mods-available/rescue_core_module.inc.php
@@ -38,9 +38,13 @@
 	 * The monitoring-Data of this module.
 	 * [0] are the actual data, [1] are the data 1 minnute ago [2] are teh data 2 minuntes...
 	 */
+
+
 	private $_monitoringData = array();
+
 	/** The rescue-Data of this module. */
 	private $_rescueData = array();
+
 
 	/**
 	 *  This function is called during ispconfig installation to determine
@@ -50,12 +54,14 @@
 		return true;
 	}
 
+
 	/**
 	 * This function is called when the module is loaded
 	 */
 	function onLoad() {
 		$this->_doRescue();
 	}
+
 
 	/**
 	 * This function is called when a change in one of the registered tables is detected.
@@ -74,7 +80,7 @@
 		 */
 		global $conf;
 		if ((!isset($conf['serverconfig']['rescue']['try_rescue'])) ||
-				((isset($conf['serverconfig']['rescue']['try_rescue'])) && ($conf['serverconfig']['rescue']['try_rescue'] !='y'))){
+			((isset($conf['serverconfig']['rescue']['try_rescue'])) && ($conf['serverconfig']['rescue']['try_rescue'] !='y'))){
 			return;
 		}
 
@@ -250,7 +256,7 @@
 		 * This means, we check the data 1 minute ago
 		 */
 		if ((!isset($this->_monitoringData[1][0]['data']['webserver'])) ||
-				((isset($this->_monitoringData[1][0]['data']['webserver'])) && ($this->_monitoringData[1][0]['data']['webserver'] != 0))){
+			((isset($this->_monitoringData[1][0]['data']['webserver'])) && ($this->_monitoringData[1][0]['data']['webserver'] != 0))){
 			/*
 			 * We do NOT have this data or we have this data, but the webserver was not down 1 minute ago.
 			 * This means, it could be, that the admin is restarting the server.
@@ -269,6 +275,17 @@
 
 		/* Set the new try counter */
 		$this->_rescueData['webserver']['try_counter'] = $tryCount;
+		
+		if ($tryCount > 2 && $conf['serverconfig']['web']['server_type'] != 'nginx') {
+			if($app->system->is_user('apache')) {
+				$app->log("Clearing semaphores table for user apache.",LOGLEVEL_WARN);
+				exec("ipcs -s | grep apache | awk '{ print $2 }' | xargs ipcrm sem");
+			}
+			if($app->system->is_user('www-data')) {
+				$app->log("Clearing semaphores table for user apache.",LOGLEVEL_WARN);
+				exec("ipcs -s | grep www-data | awk '{ print $2 }' | xargs ipcrm sem");
+			}
+		}
 
 		/* if 5 times will not work, we have to give up... */
 		if ($tryCount > 5){
@@ -322,7 +339,7 @@
 		 * This means, we check the data 1 minute ago
 		 */
 		if ((!isset($this->_monitoringData[1][0]['data']['mongodbserver'])) ||
-				((isset($this->_monitoringData[1][0]['data']['mongodbserver'])) && ($this->_monitoringData[1][0]['data']['mongodbserver'] != 0))){
+			((isset($this->_monitoringData[1][0]['data']['mongodbserver'])) && ($this->_monitoringData[1][0]['data']['mongodbserver'] != 0))){
 			/*
 			 * We do NOT have this data or we have this data, but the webserver was not down 1 minute ago.
 			 * This means, it could be, that the admin is restarting the server.
@@ -388,7 +405,7 @@
 		 * This means, we check the data 1 minute ago
 		 */
 		if ((!isset($this->_monitoringData[1][0]['data']['mysqlserver'])) ||
-				((isset($this->_monitoringData[1][0]['data']['mysqlserver'])) && ($this->_monitoringData[1][0]['data']['mysqlserver'] != 0))){
+			((isset($this->_monitoringData[1][0]['data']['mysqlserver'])) && ($this->_monitoringData[1][0]['data']['mysqlserver'] != 0))){
 			/*
 			 * We do NOT have this data or we have this data, but the webserver was not down 1 minute ago.
 			 * This means, it could be, that the admin is restarting the server.
@@ -432,8 +449,9 @@
 	 * @param type $daemon the name of the daemon
 	 */
 	private function _rescueDaemon($daemon){
-		global $conf;
+		global $app, $conf;
 
+		$app->uses('system');
 		// if you need to find all restarts search for "['init_scripts']"
 		/*
 		 * First we stop the running service "normally"
@@ -445,7 +463,7 @@
 		 * So we have to try to stop but if this will not work, we have to kill the stopping
 		 * of the service
 		 */
-		exec($conf['init_scripts'] . '/' . $daemon . ' stop && (sleep 3; kill $!; sleep 2; kill -9 $!) &> /dev/null');
+		exec($app->system->getinitcommand($daemon, 'stop').' && (sleep 3; kill $!; sleep 2; kill -9 $!) &> /dev/null');
 
 		/*
 		 * OK, we tryed to stop it normally, maybe this worked maybe not. So we have to look
@@ -456,7 +474,9 @@
 		/*
 		 * There are no more zombies left. Lets start the service..
 		 */
-		exec($conf['init_scripts'] . '/' . $daemon . ' start');
+		exec($app->system->getinitcommand($daemon, 'start'));
 	}
+
 }
+
 ?>

--
Gitblit v1.9.1