public static function deamon_stop()
 {
     $deamon_info = self::deamon_info();
     if ($deamon_info['state'] == 'ok') {
         try {
             self::callOpenzwave('/ZWaveAPI/Run/network.Stop()', 0, 30000);
         } catch (Exception $e) {
         }
     }
     $pid_file = '/tmp/openzwave.pid';
     if (file_exists($pid_file)) {
         $pid = intval(trim(file_get_contents($pid_file)));
         system::kill($pid);
     }
     system::fuserk(config::byKey('port_server', 'openzwave', 8083));
     system::kill('openZWave.py');
 }
Esempio n. 2
0
 public static function deamon_stop()
 {
     $General_Debug = config::byKey('generalDebug', 'arduidom', 0, true);
     $daemonmode = self::get_daemon_mode();
     if ($daemonmode == "KILLING" || $daemonmode == "STARTING") {
         if ($General_Debug) {
             log::add('arduidom', 'debug', "Another session of stopping daemon in progress... wait 1 minute before retry...");
         }
         return false;
     }
     if ($daemonmode != "FLASHING") {
         self::set_daemon_mode("KILLING");
     }
     if ($General_Debug) {
         log::add('arduidom', 'debug', "************************* --------------------------------------------------------------------------------------");
     }
     if ($General_Debug) {
         log::add('arduidom', 'debug', "* daemon_stop() called. *");
     }
     if ($General_Debug) {
         log::add('arduidom', 'debug', "*************************");
     }
     log::add('arduidom', 'info', 'Arret du démon...');
     $daemon_path = realpath(dirname(__FILE__) . '/../../ressources');
     touch($daemon_path . "/arduidomx.kill");
     sleep(1.5);
     $pid_file = $daemon_path . "/arduidomx.pid";
     if (file_exists($pid_file)) {
         $pid = intval(trim(file_get_contents($pid_file)));
         if (substr(jeedom::version(), 0, 1) == 2) {
             $killresult = system::kill($pid);
             if ($General_Debug) {
                 log::add('arduidom', 'debug', 'system::kill(' . $pid . ") = " . $killresult);
             }
         }
         if ($General_Debug) {
             log::add('arduidom', 'debug', "removing file " . $daemon_path . "/arduidomx.pid");
         }
         unlink($daemon_path . "/arduidomx.pid");
     }
     if ($General_Debug) {
         log::add('arduidom', 'debug', "system::fuserk(" . intval(58201) . ")");
     }
     if (substr(jeedom::version(), 0, 1) == 2) {
         system::fuserk(intval(58201));
     }
     if ($daemonmode != "FLASHING") {
         self::set_daemon_mode("KILLED");
     }
     return "OK";
 }