@param swoole_server $server
@param int           $worker_id

@return void
779539
public function onWorkerStart(swoole_server $server, $worker_id)
    {
        process_rename($this->getName() . ' worker');

        $this->console(sprintf('Server Worker[<info>%s</info>] is started [<info>%s</info>]', $server->worker_pid, $worker_id), OutputInterface::VERBOSITY_DEBUG);
    }
255468
public static function onWorkerStart($serv, $worker_id) {
		Yesf::app()->initInWorker();
		//根据类型，设置不同的进程名
		if ($serv->taskworker) {
			self::setProcessName(Yesf::app()->getConfig('name', Yesf::CONF_PROJECT) . ' task ' . $worker_id);
		} else {
			self::initHotReload($serv);
			self::setProcessName(Yesf::app()->getConfig('name', Yesf::CONF_PROJECT) . ' worker ' . $worker_id);
		}
		//清除opcache
		if (function_exists('opcache_reset')) {
			opcache_reset();
		}
		//标记一下
		Swoole::$isTaskWorker = $serv->taskworker;
		//回调
		Internal::onWorkerStart();
		Plugin::trigger('workerStart', [$serv->taskworker, $worker_id]);
	}
1162740
public function dispathToWorkerId($workerId, $type, $data = null)
    {
        get_instance()->sendToOneWorker($workerId, SwooleMarco::DISPATCHER_NAME, [$type, $data], EventDispatcher::class . "::workerDispatchEventWith");
    }
1035516
protected function configureSwooleServer()
    {
        $config = $this->app->make('config');
        $options = $config->get('swoole_http.server.options');

        // only enable task worker in websocket mode and for queue driver
        if ($config->get('queue.default') !== 'swoole' && ! $this->isWebsocket) {
            unset($options['task_worker_num']);
        }

        static::$server->set($options);
    }
1353139
public function finish(\swoole\Server $serv, $task_id, $data) {
        l('finish--$task_id:'.$task_id);
        l('finish--$data:'.$data);
    }
955009
public function restartWorker($serverId, $siteId, $workerId, $wait = true)
    {
        $this->post("servers/$serverId/sites/$siteId/workers/$workerId/restart");

        if ($wait) {
            $this->retry(30, function () use ($serverId, $siteId, $workerId) {
                $key = $this->worker($serverId, $siteId, $workerId);

                return $key->status == 'installed';
            });
        }
    }
89966
public function onWorkerStart($server, $workid) {

        try {

            //init yii2 application
            $this->yiiConfig = require_once($this->yiiConfigFile);

            //register service
            $dir = ROOT_DIR . $this->config['service']['path'];
            $namespace = $this->config['service']['namespace'];

            $yiiConfig = $this->yiiConfig;
            $dbConfig = require DB_CONFIG_FILE;
            $this->__set('onBeforeInvoke',function() use ($yiiConfig,$dbConfig) {
                $application = new Application($yiiConfig);
                $application->run();
            });
            $this->__set('onAfterInvoke',function() use ($dbConfig) {
                \Yii::$app->release($dbConfig);
                \Yii::$app = null;
            });

            $this->registerService($dir, $namespace, $server);
            $asyncDir = $dir . 'async' . DIRECTORY_SEPARATOR;
            $this->registerService($asyncDir, $namespace, $server, '_async');

            $worker_num = $this->config['setting']['worker_num'];

            if (!function_exists('cli_set_process_title')) {
                if ($workid >= $worker_num) {
                    swoole_set_process_name($this->config['server']['base.process.name'] . 'Task');
                } else {
                    swoole_set_process_name($this->config['server']['base.process.name'] . 'Worker');
                }
            } else {
                if ($workid >= $worker_num) {
                    cli_set_process_title($this->config['server']['base.process.name'] . 'Task');
                } else {
                    cli_set_process_title($this->config['server']['base.process.name'] . 'Worker');
                }
            }
        } catch(\Exception $ex) {
            $this->access_log('server exit.Exception = ' . $ex->getMessage());
        }
    }
376331
public function onPipeMessage(swoole_server $server, int $src_worker_id, $message)
    {
        return $this->doPipeMessage($server, $src_worker_id, $message);
    }
447533
public function onManagerStart(swoole_server $server)
    {
        process_rename($this->getName() . ' manager');

        $this->output->writeln(sprintf('Server Manager[<info>%s</info>] is started', $server->manager_pid), OutputInterface::VERBOSITY_DEBUG);
    }
880027
public function createWorker($serverId, $siteId, array $data, $wait = true)
    {
        $worker = $this->post("servers/$serverId/sites/$siteId/workers", $data)['worker'];

        if ($wait) {
            return $this->retry($this->getTimeout(), function () use ($serverId, $siteId, $worker) {
                $worker = $this->worker($serverId, $siteId, $worker['id']);

                return $worker->status == 'installed' ? $worker : null;
            });
        }

        return new Worker($worker + ['server_id' => $serverId, 'site_id' => $siteId], $this);
    }
1336534
public function onTask(SwServer $server, int $taskId, int $fromId, $data)
    {
        // {{ log
        $this->get('logger')->info('投递任务', [
            'id' => $taskId,
            'fromId' => $fromId,
            'data' => is_array($data) ? json_encode($data) : $data
        ]);
        // }}

        // {{
        return $this->get('task')->onTask($server, $taskId, $fromId, $data);
        // }}
    }
1092779
public function onStart(swoole_server $server)
    {
        if (version_compare(SWOOLE_VERSION, '1.9.5', '<')) {
            file_put_contents($this->pidFile, $server->master_pid);
            $this->pid = $server->master_pid;
        }

        process_rename($this->name . ' master');

        $this->output->writeln(sprintf("Listen: <info>%s://%s:%s</info>", $this->getScheme(), $this->getHost(), $this->getPort()));
        foreach ($this->listens as $listen) {
            $this->output->writeln(sprintf(" <info> ></info> Listen: <info>%s://%s:%s</info>", $listen->getScheme(), $listen->getHost(), $listen->getPort()));
        }

        $this->output->writeln(sprintf('PID file: <info>%s</info>, PID: <info>%s</info>', $this->pidFile, $server->master_pid));
        $this->output->writeln(sprintf('Server Master[<info>%s</info>] is started', $server->master_pid), OutputInterface::VERBOSITY_DEBUG);
    }
821808
private function setWorkerID($workerID)
    {
        if ($workerID >= 1 &&
            $workerID <= 255
        ) {
            return (int)$workerID;
        } elseif ($workerID !== null) {
            throw new \InvalidArgumentException('WorkerID out of range (1-255)');
        }
        return rand(1, 255);
    }
988017
public function onSwoolePipeMessage($serv, $from_worker_id, $message)
    {
        switch ($message['type']) {
            case SwooleMarco::PROCESS_RPC_RESULT:
                EventDispatcher::getInstance()->dispatch($message['message']['token'], $message['message']['result'], true);
                break;
            case SwooleMarco::PROCESS_RPC:
                $this->processPpcRun($message['message']);
                break;
            default:
                if (!empty($message['func'])) {
                    $message['func']($message['message']);
                }
        }
    }
120906
protected function changeWorkerState(string $workerId, int $workerState) : bool
    {
        $this->workerStates[$workerId] = $workerState;
        if ($workerState === Worker::WORKER_STATE_IDLE) {
            $this->pushJobs();
        }
        return true;
    }
929203
public function onShutdown(swoole_server $server)
    {
        if (file_exists($this->pidFile)) {
            unlink($this->pidFile);
        }

        $this->console(sprintf('Server <info>%s</info> Master[<info>%s</info>] is shutdown ', $this->name, $server->master_pid), OutputInterface::VERBOSITY_DEBUG);
    }
798282
public function onSwooleWorkerStart($serv, $workerId)
    {
        parent::onSwooleWorkerStart($serv, $workerId);
        $this->initAsynPools($workerId);
        //进程锁保证只有一个进程会执行以下的代码,reload也不会执行
        if (!$this->isTaskWorker() && $this->initLock->trylock()) {
            //进程启动后进行开服的初始化
            $this->onOpenServiceInitialization();
            if (Start::$testUnity) {
                $ready = ProcessManager::getInstance()->getRpcCall(CatCacheProcess::class)->isReady();
                if (!$ready) {
                    EventDispatcher::getInstance()->addOnceCoroutine(CatCacheProcess::READY);
                }
                new TestModule(Start::$testUnityDir);
            }
            $this->initLock->lock_read();
        }
        //向SDHelp進程取數據
        if (!$this->isTaskWorker()) {
            $isReload = $this->isReload();
            ConsulHelp::start();
            TimerTask::start();
            if ($this->config->get('catCache.enable', false)) {
                TimerCallBack::init();
                if (!$isReload) {
                    $ready = ProcessManager::getInstance()->getRpcCall(CatCacheProcess::class)->isReady();
                    if (!$ready) {
                        EventDispatcher::getInstance()->addOnceCoroutine(CatCacheProcess::READY);
                    }
                }
                Actor::recovery($workerId);
            }
        }
        //Code coverage
        register_tick_function([$this, 'onPhpTick']);
    }