hhxsv5 / laravel-s

LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.
MIT License
3.82k stars 470 forks source link

[QUESTION] quit property on custom process during reload #455

Closed slushpuppy closed 3 weeks ago

slushpuppy commented 1 year ago

Hi, I see the boilerplate static ::quit property which is used to control the infinite loop inside callback, may I know how this property is managed by process manager during a reload? Searching this repository, I don't see any reference of it being set back to true during a SIGUSR1 reload

hhxsv5 commented 3 weeks ago

When a custom process receives a specific signal, it will call back a specific method. SIGUSR1: onReload() SIGTERM: onStop()

// Requirements: LaravelS >= v3.4.0 & callback() must be async non-blocking program.
public static function onReload(Server $swoole, Process $process)
{
    // Stop the process...
    // Then end process
    \Log::info('Test process: reloading');
    self::$quit = true;
    // $process->exit(0); // Force exit process
}
// Requirements: LaravelS >= v3.7.4 & callback() must be async non-blocking program.
public static function onStop(Server $swoole, Process $process)
{
    // Stop the process...
    // Then end process
    \Log::info('Test process: stopping');
    self::$quit = true;
    // $process->exit(0); // Force exit process
}