示例#1
0
 /**
  * 执行Daemon任务
  */
 public final function daemonRun()
 {
     try {
         /**
          * 死循环部分
          */
         while (TRUE) {
             //脚本进程日常监测
             //新版本检测
             $this->releaseCheck();
             //内存检测等
             $this->memoryCheck();
             //调用方法
             $this->run();
             //日志强刷
             if (microtime(1) - $this->lastFlushLog > static::LOG_FORCEFLUSH_INTERVAL) {
                 //第一次不推
                 if ($this->lastFlushLog != 0) {
                     LogBase::daemonFlush();
                 }
                 $this->lastFlushLog = microtime(1);
             }
             usleep(self::CRON_SLEEP);
         }
     } catch (\Exception $e) {
         self::getLog()->add('Find DM_Module_Daemon::daemonRun Exception:' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
         die;
     }
 }