Esempio n. 1
0
function handleShutdown()
{
    global $webSocketProcess;
    if (PHP_OS == "Linux") {
        proc_terminate($webSocketProcess, 9);
        foreach (\eBot\Application\ApplicationServer::getInstance()->instance as $proc) {
            proc_terminate($proc, 9);
        }
    }
    $error = error_get_last();
    if (!empty($error)) {
        $info = "[SHUTDOWN] date: " . date("d.m.y H:m", time()) . " file: " . $error['file'] . " | ln: " . $error['line'] . " | msg: " . $error['message'] . PHP_EOL;
        file_put_contents(APP_ROOT . 'logs' . DIRECTORY_SEPARATOR . 'error.log', $info, FILE_APPEND);
    }
}
Esempio n. 2
0
 private function chooseInstance()
 {
     $instance = \eBot\Application\ApplicationServer::getInstance()->instance;
     $counter = array();
     for ($i = 1; $i <= count($instance); $i++) {
         $counter[$i] = 0;
     }
     foreach ($this->matchs as $v) {
         $counter[$v['i']] += 1;
     }
     asort($counter);
     $keys = array_keys($counter);
     $id = array_shift($keys);
     return $id;
 }