src/SMProxyServer.php
public function onWorkerStart(\swoole_server $server, int $worker_id)
    {
        self::go(function () use ($server, $worker_id) {
            if ($worker_id >= CONFIG['server']['swoole']['worker_num']) {
                ProcessHelper::setProcessTitle('SMProxy task    process');
            } else {
                ProcessHelper::setProcessTitle('SMProxy worker  process');
            }
            try {
                $this->dbConfig = $this->parseDbConfig(initConfig(CONFIG_PATH));
                //初始化链接
                MySQLPool::init($this->dbConfig);
            } catch (MySQLException $exception) {
                self::writeErrorMessage($exception, 'mysql');
                $server ->shutdown();
                return;
            } catch (SMProxyException $exception) {
                self::writeErrorMessage($exception, 'system');
                $server ->shutdown();
                return;
            }
            if ($worker_id === (CONFIG['server']['swoole']['worker_num'] - 1)) {
                try {
                    Coroutine::sleep(0.1);
                    $this ->setStartConns();
                } catch (MySQLException $exception) {
                    self::writeErrorMessage($exception, 'mysql');
                    $server ->shutdown();
                    return;
                }
                $system_log = Log::getLogger('system');
                $system_log->info('Worker started!');
                echo 'Worker started!', PHP_EOL;
            }
        });
    }
public function onWorkerStart(\swoole_server $server, int $worker_id)
    {
        self::go(function () use ($server, $worker_id) {
            if ($worker_id >= CONFIG['server']['swoole']['worker_num']) {
                ProcessHelper::setProcessTitle('SMProxy task    process');
            } else {
                ProcessHelper::setProcessTitle('SMProxy worker  process');
            }
            try {
                $this->dbConfig = $this->parseDbConfig(initConfig(CONFIG_PATH));
                //初始化链接
                MySQLPool::init($this->dbConfig);
            } catch (MySQLException $exception) {
                self::writeErrorMessage($exception, 'mysql');
                $server ->shutdown();
                return;
            } catch (SMProxyException $exception) {
                self::writeErrorMessage($exception, 'system');
                $server ->shutdown();
                return;
            }
            if ($worker_id === (CONFIG['server']['swoole']['worker_num'] - 1)) {
                try {
                    Coroutine::sleep(0.1);
                    $this ->setStartConns();
                } catch (MySQLException $exception) {
                    self::writeErrorMessage($exception, 'mysql');
                    $server ->shutdown();
                    return;
                }
                $system_log = Log::getLogger('system');
                $system_log->info('Worker started!');
                echo 'Worker started!', PHP_EOL;
            }
        });
    }
WorkerStart.

@param \swoole_server $server
@param int $worker_id