示例#1
0
 protected function initBootstraps()
 {
     /**
      * DIServer默认启动器配置目录。
      */
     return include Application::GetFrameworkPath() . '/Config/Bootstrap.php';
 }
示例#2
0
 /**
  * 进程启动时被触发
  *
  * @param \swoole_server $server    当前进程的swoole_server对象
  * @param int            $worker_id 当前进程的ID
  */
 public function OnWorkerStart(\swoole_server $server, $worker_id)
 {
     Log::Notice("On Worker[{$worker_id}] Start.");
     $workerStrapps = (include Application::GetFrameworkPath() . '/Registry/Worker.php');
     Application::AutoRegistry($workerStrapps);
     Event::Listen('OnWorkerStart', [&$server, &$worker_id]);
 }
示例#3
0
 protected function setConfig()
 {
     //加载惯例配置//一次性配置,不用保存在内存中
     $defaultConfig = (include Application::GetFrameworkPath() . '/Config/Swoole.php');
     //加载自定义配置//一次性配置,不用保存在内存中
     $serverConfig = (include Application::GetServerPath() . '/Config/Swoole.php');
     //更新配置
     foreach ($defaultConfig as $key => $value) {
         if (isset($serverConfig[$key])) {
             //如果存在Server的重定义,则重定义。
             $defaultConfig[$key] = $serverConfig[$key];
         }
         if (empty($defaultConfig[$key])) {
             //如果不存在,unset之
             unset($defaultConfig[$key]);
         }
     }
     $this->settingCheck($defaultConfig);
     $this->swoole->set($defaultConfig);
 }
示例#4
0
 /**
  * Worker进程启动时触发并划分普通worker进程和task进程
  *
  * @param \swoole_server $server
  * @param int            $worker_id
  *
  * @throws \DIServer\Container\NotRegistedException
  * @throws \DIServer\Container\NotTypeOfInstanceException
  */
 public function OnWorkerStart(\swoole_server $server, $worker_id)
 {
     //各个进程的$server对象不是同一个,要重置。
     Container::Unregister(\swoole_server::class);
     Container::RegisterClassByInstance(\swoole_server::class, $server);
     $reloadConfig = (include Application::GetFrameworkPath() . '/Registry/ServerReload.php');
     Container::AutoRegistry($reloadConfig);
     if ($server->taskworker) {
         $this->taskerServer = Container::GetInstance(ITaskWorkerServer::class);
         $this->taskerServer->OnTaskWorkerStart($server, $worker_id);
     } else {
         $this->workerServer = Container::GetInstance(IWorkerServer::class);
         $this->workerServer->OnWorkerStart($server, $worker_id);
     }
 }