异步worker重启问题

新手上路,请多包涵

问题描述

异步worker在达到max_request之后,即时设置了max_wait_time,旧worker进程也马上退出了,没有等待异步执行完再退出

问题出现的环境背景及自己尝试过哪些方法

https://wiki.swoole.com/wiki/...

环境

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
[root@localhost ~]# php72 -v
PHP 7.2.14 (cli) (built: Jan 26 2019 14:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[root@localhost ~]# php72 --ri swoole

swoole

swoole support => enabled
Version => 4.0.4
Author => Swoole Group[email: team@swoole.com]
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async redis client => enabled
async http/websocket client => enabled
openssl => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled

Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

相关代码

$http = new \Swoole\Http\Server("0.0.0.0", 9509, SWOOLE_PROCESS);
$http->set(['worker_num'=>1, 'max_request'=>3, 'max_wait_time'=>10]);
$http->on('WorkerStart', function ($server, $id) {
    echo "Swoole Work $id pid : " . $server->worker_pid . " Start\n";
});
$http->on('WorkerStop', function ($server, $id) {
    echo "Swoole Work $id pid : " . $server->worker_pid . " Stop\n";
});
$http->on('request', function ($request, $response) {
    \Swoole\Coroutine::sleep(5);
    $response->end(time());
    var_dump($request->fd);
});
$http->start();

你期待的结果是什么?实际看到的错误信息又是什么?

clipboard.png
第三个请求进来的时候,旧worker进程马上退出了,求解!!!

阅读 1.5k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进