think\exception\ErrorException: Swoole\Timer::after(): Timer must be greater than or equal to 1 in /www/wwwroot/xxxxx.com/vendor/workerman/workerman/Events/Swoole.php:76
[2021-03-05T11:13:00+08:00][ info ] {"fd":60,"flag":16,"func":{},"args":[]}
0
[2021-03-05T11:13:00+08:00][ info ] {"fd":1.0e-6,"flag":16,"func":{},"args":[]}
0
[2021-03-05T11:13:00+08:00][ info ] {"fd":1.0e-6,"flag":16,"func":{},"args":[]}
0
[2021-03-05T11:13:00+08:00][ info ] {"fd":1.0e-6,"flag":16,"func":{},"args":[]}
0
[2021-03-05T11:13:00+08:00][ info ] {"fd":60,"flag":16,"func":{},"args":[]}
打印下,看下Swoole\Timer::after() 传入的参数是什么
[2021-03-05T11:13:00+08:00][ info ] {"fd":60,"flag":16,"func":{},"args":[]}
0
[2021-03-05T11:13:00+08:00][ info ] {"fd":1.0e-6,"flag":16,"func":{},"args":[]}
0
[2021-03-05T11:13:00+08:00][ info ] {"fd":1.0e-6,"flag":16,"func":{},"args":[]}
0
[2021-03-05T11:13:00+08:00][ info ] {"fd":1.0e-6,"flag":16,"func":{},"args":[]}
0
[2021-03-05T11:13:00+08:00][ info ] {"fd":60,"flag":16,"func":{},"args":[]}
有个fd为1.0e-6,按照代码里写的*1000后为0.01,就报错了,Swoole\Timer::after()的时间指本来就是毫秒了,但却传了一个0.01,那不是workerman/workerman/Events/Swoole.php的问题,而是workerman/crontab那边时间转换传递的值不对吧?
目前我用到的cron表达式
0 /1
0 0 8
/3
0 0 1,9,12,18 *
在\Workerman\Crontab\Crontab 162行
Timer::add($t*1000, $cb, null, false);
在这里加入*1000就正常了(只针对Swoole),应该不是规范的解决方案,还望作者修正。
在\Workerman\Crontab\Crontab 162行
Timer::add($t*1000, $cb, null, false);
在这里加入*1000就正常了(只针对Swoole),应该不是规范的解决方案,还望作者修正。
\Workerman\RedisQueue\Client 239行也存在这个问题,需要对Swoole环境下*1000
更新workerman到4.0.19或者后续的更高版本试下。
composer require workerman/workerman ^4.0.19
感谢,可以了。