changeUser() static public method

改变进程的用户ID
static public changeUser ( $user ) : boolean
$user
return boolean
Example #1
0
 function onStart($serv, $worker_id = 0)
 {
     if (!defined('WEBROOT')) {
         define('WEBROOT', $this->config['server']['webroot']);
     }
     if (isset($this->config['server']['user'])) {
         Swoole\Console::changeUser($this->config['server']['user']);
     }
     Swoole\Error::$echo_html = true;
     $this->swoole_server = $serv;
     Swoole::$php->server = $this;
     $this->log(self::SOFTWARE . "[#{$worker_id}]. running. on {$this->server->host}:{$this->server->port}");
     register_shutdown_function(array($this, 'onError'));
 }
 function onStart($serv, $worker_id = 0)
 {
     global $yaf;
     if (!defined('WEBROOT')) {
         define('WEBROOT', $this->config['server']['webroot']);
     }
     if (isset($this->config['server']['user'])) {
         Swoole\Console::changeUser($this->config['server']['user']);
     }
     $this->application = new \Yaf_Application(WEBPATH . "/conf/application.ini");
     $yaf->application = $this->application;
     Swoole\Error::$echo_html = true;
     $this->swoole_server = $serv;
     //Swoole::$php->server = $this;
     $this->log(self::SOFTWARE . "[#{$worker_id}]. running. on {$this->server->host}:{$this->server->port}");
     set_error_handler(array($this, 'onErrorHandle'), E_USER_ERROR);
     register_shutdown_function(array($this, 'onErrorShutDown'));
 }
 function onStart($serv, $worker_id = 0)
 {
     if (!defined('WEBROOT')) {
         define('WEBROOT', $this->config['server']['webroot']);
     }
     if (isset($this->config['server']['user'])) {
         Swoole\Console::changeUser($this->config['server']['user']);
     }
     if ($this->server instanceof Swoole\Network\Server and isset($this->config['server']['process_rename'])) {
         global $argv;
         if ($worker_id >= $serv->setting['worker_num']) {
             Swoole\Console::setProcessName('php ' . $argv[0] . ': task');
         } else {
             Swoole\Console::setProcessName('php ' . $argv[0] . ': worker');
         }
     }
     Swoole\Error::$echo_html = true;
     $this->swoole_server = $serv;
     Swoole::$php->server = $this;
     $this->log(self::SOFTWARE . "[#{$worker_id}]. running. on {$this->server->host}:{$this->server->port}");
     register_shutdown_function(array($this, 'onError'));
 }
Example #4
0
 public function onWorkerStart($server, $workerId)
 {
     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);
     }
     // check protocol class
     if (!$this->protocol) {
         throw new \Exception("[error] the protocol class  is empty or undefined");
     }
     $this->protocol->onStart($server, $workerId);
 }