Esempio n. 1
0
 /**
  * (PmaControl 0.8)<br/>
  * @author Aurélien LEQUOY, <*****@*****.**>
  * @return boolean Success
  * @package Controller
  * @since 0.8 First time this was introduced.
  * @description launch a subprocess limited in time to try MySQL connection, if ok get status and show master/slave status
  * @access public
  */
 private function testMysqlServer($server, $max_execution_time = 10)
 {
     $this->view = false;
     //exeute a process with a timelimit (in case of MySQL don't answer and keep connection)
     //$max_execution_time = 20; // in seconds
     $ret = SetTimeLimit::run("Agent", "tryMysqlConnection", array($server['name'], $server['id']), $max_execution_time);
     if (!SetTimeLimit::exitWithoutError($ret)) {
         /* in case of somthing wrong :
          * server don't answer
          * server didn't give msg 
          * wrong credentials
          * error in PHP script
          */
         $db = $this->di['db']->sql(DB_DEFAULT);
         //in case of no answer provided we create a msg of error
         if (empty($ret['stdout'])) {
             $ret['stdout'] = "[" . date("Y-m-d H:i:s") . "]" . " Server MySQL didn't answer in time (delay max : " . $max_execution_time . " seconds)";
         }
         $sql = "UPDATE mysql_server SET `error`='" . $db->sql_real_escape_string($ret['stdout']) . "', `date_refresh`='" . date("Y-m-d H:i:s") . "' where id = '" . $server['id'] . "'";
         $db->sql_query($sql);
         //echo $sql . "\n";
         $sql = "UPDATE mysql_replication_stats SET is_available = 0 where id_mysql_server = '" . $server['id'] . "'";
         $db->sql_query($sql);
         $db->sql_close();
         echo $this->debug ? $server['name'] . " KO :\n" : "";
         $this->debug ? print_r($ret) : '';
         return false;
     } else {
         //echo ($this->debug) ? $server['name']." OK \n" : "";
         return true;
     }
 }
Esempio n. 2
0
 function timeOut()
 {
     $this->view = false;
     $ret = \Glial\Cli\SetTimeLimit::run("Test2", "hello", array("fgchfdg", "dfgdfg"), 2);
     if (empty($ret)) {
         echo "script under timeout and successful\n";
     } elseif (is_int($ret)) {
         echo "Error in script !\n";
     } elseif (is_array($ret)) {
         echo "timeout !\n";
         debug($ret);
     } else {
         $this->di['log']->emergency("PMA-CTRL ANORMAL CASE !", $ret);
     }
 }