yzh52521/webman-task这个插件的定时任务,出现skipped execution

kylin87

bug描述

修改,重启任务,均无效,甚至restart项目也不行,它也会定期执行,但是每次都是skipped execution

程序代码或配置

worker:0 [2023-02-16 09:53:29] Crontab task [更新城市] skipped execution at 2023-02-16 09:53:29. [Ok] 
worker:0 [2023-02-16 09:54:26] Crontab task [更新城市] skipped execution at 2023-02-16 09:54:26. [Ok] 
worker:0 [2023-02-16 09:57:02] Crontab task [更新城市] skipped execution at 2023-02-16 09:57:02

重现bug的步骤

不管是命令,还是url还是类都有这个情况,明明任务已经设置开启和重复,但是不执行
上面跳过的这个,甚至都没有修改任务,仅仅是因为报错,重启了restart了项目了,就出现这个了。
好像每次都是因为重启了项目就出现这个了

系统环境及workerman/webman等具体版本

centos系统,最新的webman,1.4版本的yzh52521/webman-task

885 3 0
3个回答

kylin87
<?php

namespace app\common\crontab;

use support\Log;

class UpdateCity
{
    public function execute()
    {
        Log::channel('star')->info(date('Y-m-d H:i:s') . '执行了更新城市');
        return true;
    }   
}

任务中目前没有写逻辑,只写了一个日志

  • yzh52521 2023-02-16

    删除 redis里 framework/crontab- 这个key

  • yzh52521 2023-02-16

    升级 1.41 重启项目会清理之前未删除的 key

  • kylin87 2023-02-16

    更新到1.41后,可以执行了,但是仍然报错
    PHP Fatal error: Cannot declare class app\common\crontab\UpdateCity, because the name is already in use in /www/wwwroot/yhs-web/app/common/crontab/UpdateCity.php on line 10

  • yzh52521 2023-02-16

    这个是 你代码的错误

  • kylin87 2023-02-16

    我的代码上面展示了,只写了一句日志,然后返回true

  • kylin87 2023-02-16

    第一次执行,没有报错,但是fail,第二次执行出现上面的错误

  • kylin87 2023-02-16

    我把任务写成了命令行,可以了。但是类的问题可能还未解决。另外升级1.41后,修改任务的时候又报错了,1.4的时候还没事。
    [2023-02-16 11:37:34] default.ERROR: 172.17.0.1 POST 127.0.0.1:8787/app/admin/th-system-crontab/update
    TypeError: json_decode() expects parameter 1 to be string, bool given in /www/wwwroot/yhs-web/vendor/yzh52521/webman-task/src/Client.php:33
    Stack trace:
    0 /www/wwwroot/yhs-web/vendor/yzh52521/webman-task/src/Client.php(33): json_decode()

  • yzh52521 2023-02-16

    我测试没有问题的

kylin87

刚开始的时候,是可以执行的,但是出现了这个报错
PHP Fatal error: Cannot declare class app\common\crontab\UpdateCity, because the name is already in use

  • 暂无评论
kylin87

更新到1.41后,可以执行了,但是仍然报错
PHP Fatal error: Cannot declare class app\common\crontab\UpdateCity, because the name is already in use in /www/wwwroot/yhs-web/app/common/crontab/UpdateCity.php on line 10

  • charlescc 2023-11-03

    偶然我也碰到了这个问题,但解决了。可以把你调用 类的 所传的class 路径贴一下吗。

年代过于久远,无法发表回答
🔝