swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.04k stars 390 forks source link

feat: add hook action for http server #469

Closed kocoten1992 closed 3 years ago

kocoten1992 commented 3 years ago

Previously, there is no way (?) to hook up and run a script before http start.

This patch allowed user to extends our class with hookAction run custom script before starting server up.

leocarmo commented 3 years ago

Good! There is an example to show how i can implement this on a right way?

kocoten1992 commented 3 years ago

@leocarmo you can extends it normally, it will overwrite the default command

<?php

namespace App\Console\Commands;

use SwooleTW\Http\Commands\HttpServerCommand;

class TestCommand extends HttpServerCommand
{
    protected $signature = 'swoole:http {action : start|stop|restart|reload|infos}';

    protected function hookAction()
    {
        echo 'hook between init and run';
    }
}