in provider/core/server/BaseServer.php [423:474]
public function onWorkerStart($server, $workerId)
{
if($server->taskworker)
{
// rename task process
Console::setProcessName($this->processName.'_task_worker_process');
}
else
{
// rename work process
Console::setProcessName($this->processName.'_event_worker_process');
}
if ($this->user)
{
Console::changeUser($this->user);
}
//启动app
//log系统初始化需要用到processName,暂时以常量方式处理
if(!defined('FSOF_PROVIDER_APP_NAME')) define('FSOF_PROVIDER_APP_NAME', $this->processName);
$AppLauncherPath = dirname(__DIR__).DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'AppLauncher.php';
require_once $AppLauncherPath;
$protocol = AppLauncher::createApplication($this->requireFile);
if (!$protocol)
{
$this->logger->error('the protocol class is empty or undefined');
throw new \Exception('[error] the protocol class is empty or undefined');
}
$this->setProtocol($protocol);
//设置appContext
$this->appContext = new AppContext();
//set service statusless
$service_properties = isset($this->config['service_properties']) ? $this->config['service_properties'] : array();
if (isset($service_properties['stateless']))
{
$this->appContext->setStateless($service_properties['stateless'], $this);
}
else
{
$this->appContext->setStateless(FALSE, $this);
}
$this->logger->debug("workerId [{$workerId}] start ok");
$this->protocol->onStart($server, $workerId);
//设置全局exception,错误处理函数,放在最后,则相关异常错误信息都会被框架捕捉处理
set_exception_handler(array($this, 'exceptionHandler'));
set_error_handler(array($this, 'errorHandler'));
register_shutdown_function(array($this, 'fatalHandler'));
}