swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 788 forks source link

自定义进程池restart/stop.start命令,在walle2.0自动部署中,进程kill后无法启动新进程 #1071

Open phenixsoul opened 4 years ago

phenixsoul commented 4 years ago
Q A
Bug report? yes
Swoft version 2.0.6
Swoole version 4.4.4
PHP version 7.3.6
Runtime environment Win10/Mac/CentOS 7/Ubuntu/Docker etc.

Describe the bug 手动执行命令行中巧 restart命令,或者stop.start命令,能够完成自定义进程池的重启工作,但是放到自动化部署平台walle2.0中,虽然命令执行成功,但是没有新的进程启动,runtime下也无相应的pid文件生成,如下:

2019/10/29-11:32:33 [INFO] Swoft\Processor\EnvProcessor:handle(52) Env file(/data/release/swoft/sxx_order/order_auto/.env) is loaded 2019/10/29-11:32:34 [INFO] Swoft\Processor\AnnotationProcessor:handle(45) Annotations is scanned(autoloader 31, annotation 383, parser 92) 2019/10/29-11:32:34 [INFO] Swoft\Processor\BeanProcessor:handle(55) config path=/data/release/swoft/sxx_order/order_auto/app/../config 2019/10/29-11:32:34 [INFO] Swoft\Processor\BeanProcessor:handle(56) config env=test 2019/10/29-11:32:34 [INFO] Swoft\Processor\BeanProcessor:handle(60) Bean is initialized(singleton 266, prototype 69, definition 55) 2019/10/29-11:32:34 [INFO] Swoft\Processor\EventProcessor:handle(33) Event manager initialized(54 listener, 5 subscriber) 2019/10/29-11:32:34 [INFO] Swoft\WebSocket\Server\Listener\AppInitCompleteListener:handle(35) WebSocket server route registered(module 0, message command 0) 2019/10/29-11:32:34 [INFO] Swoft\Tcp\Server\Listener\AppInitCompleteListener:handle(37) Tcp server route registered(routes 0) 2019/10/29-11:32:34 [INFO] Swoft\Error\Listener\AppInitCompleteListener:handle(34) Error manager init completed(0 type, 0 handler, 0 exception) 2019/10/29-11:32:34 [INFO] Swoft\Processor\ConsoleProcessor:handle(38) Console command route registered (group 11, command 37) Process pool restart success !

linux ps 命令,无相关进程:

bash-4.2$ ps aux | grep order-aut www 25760 0.0 0.0 112652 944 pts/118 R+ 12:20 0:00 grep order-aut

临时解决方法是,写了个shell脚本,用了sleep 2,休眠2秒,然后start,进程才被启动

php bin/swoft process:stop echo "begin sleep 2s" sleep 2 php bin/swoft process:start -d

bash-4.2$ ps aux | grep order-aut www 24108 0.0 0.1 237216 25820 ? Ss 12:23 0:00 order-auto-swoft-process-master www 24109 0.0 0.1 241532 29152 ? S 12:23 0:00 order-auto-swoft-process-worker www 24110 0.0 0.1 241532 29152 ? S 12:23 0:00 order-auto-swoft-process-worker www 25182 0.0 0.0 112652 940 pts/118 R+ 12:23 0:00 grep order-aut

phenixsoul commented 4 years ago

另外补充一点,在无进程的时候第一次部署大概率能启动,在有进程的时候第二次和以上部署,不管restart 还是 stop start,大概率不能启动,小概率能启动,所以我用了shell脚本尝试了sleep 2,发现成功了,不想看源代码啥原因了,所以麻烦你们了 @inhere

inhere commented 4 years ago

@phenixsoul 更新下swoole版本呢?进程的停止失败等问题,一般是swoole这里没处理好。

phenixsoul commented 4 years ago

@inhere 更新了2.0.7,升级正常了