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

Support swoole onWorkerExit #90

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

Support swoole onWorkerExit #90

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

Comments

@linuxd3v
Copy link
Contributor

linuxd3v commented Jun 13, 2022

Feature Request

Q A
New Feature yes
RFC not sure
BC Break no

Summary

At the momen mezzio/swoole supports some swoole events - however not all.
Specifically workerstop is supported, but not workerexit for example.

Per docs - workerstop is not triggering for task processes: https://github.com/deminy/swoole-by-examples/blob/master/examples/servers/server-events.php.

Event "onWorkerStop" happens in worker processes only. It won't happen in task worker processes.
Event "onWorkerExit" happens only when option \Swoole\Constant::OPTION_RELOAD_ASYNC is turned on.

this could be problematic if one needs to do some work on task worker exit - like shutdown connection pool for example.

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']);

       //lets add this!
        $this->httpServer->on('workerexit', [$this, 'onWorkerExit']);

        $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']);

        $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