public static function init() { if (self::$initialized) { return NULL; } openlog(self::$ident, array_sum(array_keys(self::$options, true)), self::$facility); self::$initialized = true; }
public static function kill() { Octave_pool::killAll(); if (self::$child_process) { exit; } while (self::$child_pids) { // Waiting for all the children to die while (-1 != ($pid = pcntl_waitpid(-1, $status))) { self::manageDeadPID($pid); } if (self::$child_pids) { usleep(100); } } self::closeServerSockets(); Octave_logger::log("Service stopped"); exit; }
public static function manageConnections() { $still_waiting = array(); foreach (self::$pending_connections as $cSocket) { if ($kid =& self::getChild($cSocket)) { $pid = pcntl_fork(); if ($pid == -1) { Octave_logger::log("Failed forking!", LOG_ERR); exit; } elseif ($pid) { // Parent Octave_daemon::$child_pids[$pid] = true; $kid->pid = $pid; $kid->close(); } else { // Child Octave_daemon::childMode(); chdir(self::$home_directory); $kid->entertain(); $kid->killSocket(); exit; } } else { $still_waiting[] = $cSocket; } } self::$pending_connections = $still_waiting; }
protected function respond($response) { while (true) { $partial = $response['partial']; // This is partial, because the errors always follow if (!$this->write($response['response'], true)) { return $this->controller->everything() && false; } if (!$partial) { if ($response['error']) { Octave_logger::log("[" . $this->remoteIP . "] " . $response['error'], LOG_WARNING); } return $this->write(self::error_start . $response['error'], $partial); } $response = array('response' => $this->controller->more(), 'error' => $this->controller->lastError, 'partial' => $this->controller->partialResult); } }
protected function setError($message, $priority = LOG_WARNING) { Octave_logger::getCurrent()->log($message, $priority); $this->lastError = $message; }