laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.78k stars 296 forks source link

When using swoole, octane:stop octane:reload can not work normally #197

Closed eleven26 closed 3 years ago

eleven26 commented 3 years ago

Description:

When using swoole, the server started by php artisan octance:start --server=swoole cannot be stopped by octane:stop.

Steps To Reproduce:

./vendor/bin/sail up
./vendor/bin/sail shell
ps -ef
sail        27    20  0 11:44 ?        00:00:00 swoole_http_server: master process for Laravel
sail        28    27  0 11:44 ?        00:00:00 swoole_http_server: manager process for Laravel
sail        31    28  1 11:44 ?        00:00:00 /usr/bin/php8.0 swoole-server /var/www/html/storage/logs/octane-server-state.json
sail        32    28  1 11:44 ?        00:00:00 /usr/bin/php8.0 swoole-server /var/www/html/storage/logs/octane-server-state.json
sail        33    28  1 11:44 ?        00:00:00 /usr/bin/php8.0 swoole-server /var/www/html/storage/logs/octane-server-state.json
sail        34    28  1 11:44 ?        00:00:00 /usr/bin/php8.0 swoole-server /var/www/html/storage/logs/octane-server-state.json
php artisan octane:stop --server=swoole
ps -ef

The final state:

sail        27    20  0 11:44 ?        00:00:00 swoole_http_server: master process for Laravel
sail        28    27  0 11:44 ?        00:00:00 [php8.0] <defunct>

The php related process has a master process and a zombie process. The zombie process is the previous manager process.

octane:reload

Before reload:

sail        27    20  0 12:18 ?        00:00:00 swoole_http_server: master process for Laravel
sail        28    27  0 12:18 ?        00:00:00 swoole_http_server: manager process for Laravel
sail        31    28  0 12:18 ?        00:00:00 /usr/bin/php8.0 swoole-server /var/www/html/storage/logs/octane-server-state.json
sail        32    28  0 12:18 ?        00:00:00 /usr/bin/php8.0 swoole-server /var/www/html/storage/logs/octane-server-state.json
sail        33    28  0 12:18 ?        00:00:00 /usr/bin/php8.0 swoole-server /var/www/html/storage/logs/octane-server-state.json
sail        34    28  0 12:18 ?        00:00:00 /usr/bin/php8.0 swoole-server /var/www/html/storage/logs/octane-server-state.json

After reload:

sail        27    20  0 12:18 ?        00:00:00 swoole_http_server: master process for Laravel
sail        28    27  0 12:18 ?        00:00:00 swoole_http_server: manager process for Laravel
sail        52    28  3 12:19 ?        00:00:00 swoole_http_server: manager process for Laravel
sail        53    28  3 12:19 ?        00:00:00 swoole_http_server: manager process for Laravel
sail        54    28  3 12:19 ?        00:00:00 swoole_http_server: manager process for Laravel
sail        55    28  3 12:19 ?        00:00:00 swoole_http_server: manager process for Laravel

After the octane:reload command is executed, the worker process is gone, and a corresponding number of manager processes are generated instead.

nunomaduro commented 3 years ago

@eleven26 Can you try this again with the latest master?

eleven26 commented 3 years ago

@nunomaduro I tried it with the latest version, now it can stop and reload normally, thanks