예제 #1
0
 function onStart($serv, $worker_id = 0)
 {
     //用户修改
     $server = $this->server->getConfig();
     if (!empty($server['user'])) {
         Console::changeUser($server['user']);
     }
     if (!empty($server['name'])) {
         if ($worker_id >= $serv->setting['worker_num']) {
             Console::setProcessName('php ' . $server['name'] . ': task');
         } else {
             Console::setProcessName('php ' . $server['name'] . ': worker');
         }
     }
     Console::output($server['name'] . "[#{$worker_id}]. running. on {$server['host']}:{$server['port']}");
     register_shutdown_function(array($this, 'onError'));
 }
예제 #2
0
파일: Server.php 프로젝트: delphinBlue/tsf
 public function onWorkerStart($server, $workerId)
 {
     // echo __METHOD__;
     // exit();
     if ($workerId >= $this->setting['worker_num']) {
         Console::setProcessName($this->processName . ': task worker process');
     } else {
         Console::setProcessName($this->processName . ': event worker process');
     }
     if ($this->user) {
         Console::changeUser($this->user);
     }
     $protocol = (require_once $this->requireFile);
     //执行
     $this->setProtocol($protocol);
     // check protocol class
     if (!$this->protocol) {
         throw new \Exception("[error] the protocol class  is empty or undefined");
     }
     $this->protocol->onStart($server, $workerId);
 }
예제 #3
0
 public function onWorkerStart($server, $workerId)
 {
     // echo __METHOD__;
     // exit();
     if ($workerId >= $this->setting['worker_num']) {
         Console::setProcessName($this->processName . ': task worker process');
     } else {
         Console::setProcessName($this->processName . ': event worker process');
     }
     if ($this->user) {
         Console::changeUser($this->user);
     }
     foreach ($this->requireFile as $v) {
         include_once $v;
     }
     if ($this->serverClass && class_exists($this->serverClass)) {
         $this->setProtocol(new $this->serverClass());
     }
     // check protocol class
     if (!$this->protocol) {
         throw new \Exception("[error] the protocol class " . $this->serverClass . " is empty or undefined");
     }
     $this->protocol->onStart($server, $workerId);
 }