src/Leevel/Protocol/Server.php
public function onStart(SwooleServer $server): void
    {
        $this->log(
            sprintf(
                'Server is started at %s:%d',
                $this->option['host'], $this->option['port']
            ),
            true, ''
        );

        $this->log('Server master worker start', true);

        $this->setProcessName($this->option['process_name'].'.master');

        $pid = $server->master_pid."\n".$server->manager_pid;

        $dirname = dirname($this->option['pid_path']);

        if (!is_writable($dirname) ||
            !file_put_contents($this->option['pid_path'], $pid)) {
            throw new InvalidArgumentException(
                sprintf('Dir %s is not writeable.', $dirname)
            );
        }

        chmod($this->option['pid_path'], 0666 & ~umask());

        // 开启验证模式
        //Runtime::enableStrictMode();
    }
public function onStart(SwooleServer $server): void
    {
        $this->log(
            sprintf(
                'Server is started at %s:%d',
                $this->option['host'], $this->option['port']
            ),
            true, ''
        );

        $this->log('Server master worker start', true);

        $this->setProcessName($this->option['process_name'].'.master');

        $pid = $server->master_pid."\n".$server->manager_pid;

        $dirname = dirname($this->option['pid_path']);

        if (!is_writable($dirname) ||
            !file_put_contents($this->option['pid_path'], $pid)) {
            throw new InvalidArgumentException(
                sprintf('Dir %s is not writeable.', $dirname)
            );
        }

        chmod($this->option['pid_path'], 0666 & ~umask());

        // 开启验证模式
        //Runtime::enableStrictMode();
    }
主进程的主线程
记录进程 id,脚本实现自动重启.

@param \Swoole\Server $server

@see https://wiki.swoole.com/wiki/page/p-event/onStart.html