Пример #1
0
 private function _mainLoop()
 {
     Tool_Log::info("daemon:{$this->name} main start");
     Tool_Proc::setTitle("daemon:{$this->name} main");
     $pid = posix_getpid();
     while (true) {
         // 检查pid文件
         if (!file_exists($this->pidFile) || $pid != file_get_contents($this->pidFile)) {
             break;
         }
         // 检查子进程状态
         foreach ($this->children as $index => $child) {
             $msg = fgets($child['socket']);
             if (feof($child['socket'])) {
                 $this->_spawnChild($index);
             }
         }
         usleep(self::CHECK_INTERVAL * 1000 * 1000);
     }
     Tool_Log::info("daemon:{$this->name} main stop");
     exit;
 }
Пример #2
0
 private function _doStop()
 {
     if (true !== $this->controllerObj->getLogRequest()) {
         return;
     }
     $info = array('elapse' => sprintf('%.3f', microtime(true) - SYSTEM_START_TIME), 'uri' => Comm_Context::getServer('REQUEST_URI'), 'params' => $this->controllerObj->getParams());
     Tool_Log::info('request ok, ' . Tool_Json::encode($info));
 }