Example #1
0
 /**
  * 初始化一些环境变量
  * @return void
  */
 protected static function init()
 {
     // 如果没设置$pidFile,则生成默认值
     if (empty(self::$pidFile)) {
         $backtrace = debug_backtrace();
         self::$_startFile = $backtrace[count($backtrace) - 1]['file'];
         self::$pidFile = __DIR__ . "/../" . str_replace('/', '_', self::$_startFile) . ".pid";
     }
     // 没有设置日志文件,则生成一个默认值
     if (empty(self::$logFile)) {
         self::$logFile = __DIR__ . '/../workerman.log';
     }
     // 标记状态为启动中
     self::$_status = self::STATUS_STARTING;
     // 启动时间戳
     self::$_globalStatistics['start_timestamp'] = time();
     // 设置status文件位置
     self::$_statisticsFile = sys_get_temp_dir() . '/workerman.status';
     // 尝试设置进程名称(需要php>=5.5或者安装了proctitle扩展)
     self::setProcessTitle('WorkerMan: master process  start_file=' . self::$_startFile);
     // 初始化id
     self::initId();
     // 初始化定时器
     Timer::init();
 }