Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BeforeServerStartEvent #91

Open
linuxd3v opened this issue Jun 13, 2022 · 0 comments
Open

Add BeforeServerStartEvent #91

linuxd3v opened this issue Jun 13, 2022 · 0 comments
Labels
Enhancement New feature or request Feature Request

Comments

@linuxd3v
Copy link
Contributor

Feature Request

Q A
New Feature yes
RFC not sure
BC Break no

Summary

With swoole certain operations could only happen before the server start. (one example is - one can only add swoole processes to swoole server before server starts.)
For this reason I think it would be worthwhile to add BeforeServerStartEvent.

Could probably be easily addressed in Mezzio\Swoole\SwooleRequestHandlerRunner:

    public function run(): void
    {
        if ($this->httpServer->mode === SWOOLE_PROCESS) {
            $this->httpServer->on('start', [$this, 'onStart']);
            $this->httpServer->on('shutdown', [$this, 'onShutdown']);
        }

        $this->httpServer->on('managerstart', [$this, 'onManagerStart']);
        $this->httpServer->on('managerstop', [$this, 'onManagerStop']);
        $this->httpServer->on('workerstart', [$this, 'onWorkerStart']);
        $this->httpServer->on('workerstop', [$this, 'onWorkerStop']);
        $this->httpServer->on('workererror', [$this, 'onWorkerError']);
        $this->httpServer->on('request', [$this, 'onRequest']);
        $this->httpServer->on('beforereload', [$this, 'onBeforeReload']);
        $this->httpServer->on('afterreload', [$this, 'onAfterReload']);
        $this->httpServer->on('task', [$this, 'onTask']);
        $this->httpServer->on('finish', [$this, 'onTaskFinish']);

       //lets add this!
        $this->dispatcher->dispatch(new Event\BeforeServerStartEvent($server));

        $this->httpServer->start();
    }
@linuxd3v linuxd3v added the Enhancement New feature or request label Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Feature Request
Projects
None yet
Development

No branches or pull requests

2 participants