Closed licclicc closed 1 year ago
创建task的时候报的,参数都对
开启依赖注入
------------------ 原始邮件 ------------------ 发件人: licclicc @.> 发送时间: 2023年5月10日 19:43 收件人: yzh52521/webman-task @.> 抄送: Subscribed @.***> 主题: Re: [yzh52521/webman-task] 执行报错,RedisTaskMutex这个方法好像有问题 (Issue #9)
创建task的时候报的,参数都对
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
这就是开启依赖注入之后报的错,以下是composer.json
{ "name": "workerman/webman", "type": "project", "keywords": [ "high performance", "http service" ], "homepage": "https://www.workerman.net", "license": "MIT", "description": "High performance HTTP Service Framework.", "authors": [ { "name": "walkor", "email": "walkor@workerman.net", "homepage": "https://www.workerman.net", "role": "Developer" } ], "support": { "email": "walkor@workerman.net", "issues": "https://github.com/walkor/webman/issues", "forum": "https://wenda.workerman.net/", "wiki": "https://workerman.net/doc/webman", "source": "https://github.com/walkor/webman" }, "require": { "php": ">=7.2", "workerman/webman-framework": "^1.5.0", "monolog/monolog": "^2.0", "webman/admin": "^0.6.8", "psr/container": "^1.1.1", "webman/console": "^1.2.13", "illuminate/events": "^9.52", "symfony/cache": "^6.0", "webman/stomp": "^1.1", "workbunny/webman-ip-attribution": "^1.0", "yzh52521/easyhttp": "^1.0", "hhink/webman-sms": "^1.0", "shopwwi/webman-scout": "^1.1", "yzh52521/webman-lock": "^1.0", "elasticsearch/elasticsearch": "^7.17", "illuminate/redis": "^9.52", "shopwwi/webman-filesystem": "^1.0", "shopwwi/filesystem-oss": "^1.0", "webman/channel": "^1.0", "tinywan/jwt": "^1.6", "sunsgne/annotations": "^1.1", "illuminate/database": "^9.52", "illuminate/pagination": "^9.52", "symfony/var-dumper": "^6.0", "vlucas/phpdotenv": "^5.5", "workerman/crontab": "^1.0", "phpoffice/phpspreadsheet": "^1.28", "yansongda/pay": "~3.2.0", "workbunny/webman-rabbitmq": "^1.0", "yzh52521/webman-mailer": "^1.1", "yzh52521/webman-task": "dev-lv", "php-di/php-di": "^6", "doctrine/annotations": "^1.14" }, "suggest": { "ext-event": "For better performance. " }, "autoload": { "psr-4": { "": "./", "app\": "./app", "App\": "./app", "app\View\Components\": "./app/view/components" }, "files": [ "./support/helpers.php" ] }, "scripts": { "post-package-install": [ "support\Plugin::install" ], "post-package-update": [ "support\Plugin::install" ], "pre-package-uninstall": [ "support\Plugin::uninstall" ] } }
确定都已经安装了,以下是我再次执行安装的结果
[www@yqyldev yqylgzt]$ composer require psr/container ^1.1.1 php-di/php-di ^6 doctrine/annotations ^1.14 ./composer.json has been updated Running composer update psr/container php-di/php-di doctrine/annotations Loading composer repositories with package information Info from https://repo.packagist.org: #StandWithUkraine Updating dependencies Nothing to modify in lock file Installing dependencies from lock file (including require-dev) Nothing to install, update or remove Generating autoload files 57 packages you are using are looking for funding. Use the `composer fund` command to find out more! No security vulnerability advisories found [www@yqyldev yqylgzt]$
以下是我在Client.php添加的测试代码。这个地方是空的
public function request(array $param) { fwrite($this->client, json_encode($param,JSON_UNESCAPED_UNICODE) . "\n"); // text协议末尾有个换行符"\n" $result = fgets($this->client, 10240000); print("这是个 tcp text: ".$result); return json_decode($result); }
下面是执行添加一个定时任务返回的报错,但是数据库里面添加进去了
{ "code": 500, "msg": "json_decode(): Argument #1 ($json) must be of type string, bool given", "type": "failed", "traces": "TypeError: json_decode(): Argument #1 ($json) must be of type string, bool given in /home/www/app/licc/yqylgzt/vendor/yzh52521/webman-task/src/Client.php:36\nStack trace:\n#0 /home/www/app/licc/yqylgzt/vendor/yzh52521/webman-task/src/Client.php(36): json_decode()\n#1 /home/www/app/licc/yqylgzt/plugin/admin/app/controller/SystemCrontabController.php(61): yzh52521\\Task\\Client->request()\n#2 /home/www/app/licc/yqylgzt/vendor/workerman/webman-framework/src/App.php(319): plugin\\admin\\app\\controller\\SystemCrontabController->insert()\n#3 /home/www/app/licc/yqylgzt/vendor/workerman/webman-framework/src/App.php(349): Webman\\App::Webman\\{closure}()\n#4 /home/www/app/licc/yqylgzt/plugin/admin/app/middleware/AccessControl.php(47): Webman\\App::Webman\\{closure}()\n#5 /home/www/app/licc/yqylgzt/vendor/workerman/webman-framework/src/App.php(341): plugin\\admin\\app\\middleware\\AccessControl->process()\n#6 /home/www/app/licc/yqylgzt/vendor/workerman/webman-framework/src/App.php(168): Webman\\App::Webman\\{closure}()\n#7 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Connection/TcpConnection.php(646): Webman\\App->onMessage()\n#8 [internal function]: Workerman\\Connection\\TcpConnection->baseRead()\n#9 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()\n#10 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Worker.php(1629): Workerman\\Events\\Event->loop()\n#11 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Worker.php(1423): Workerman\\Worker::forkOneWorkerForLinux()\n#12 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Worker.php(1397): Workerman\\Worker::forkWorkersForLinux()\n#13 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Worker.php(560): Workerman\\Worker::forkWorkers()\n#14 /home/www/app/licc/yqylgzt/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\\Worker::runAll()\n#15 /home/www/app/licc/yqylgzt/start.php(4): support\\App::run()\n#16 {main}" }
修改配置config/container.php 了么
没修改配置config/container.php
没修改配置config/container.php
不修改 没有依赖注入
感谢大神,修改过就不报错了
在 2023-05-11 10:30:20,"听风吹雨" @.***> 写道:
没修改配置config/container.php
不修改 没有依赖注入
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
感谢大神,修改过就不报错了 在 2023-05-11 10:30:20,"听风吹雨" @.> 写道: 没修改配置config/container.php 不修改 没有依赖注入 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>
给你发手册地址就是让你看全 不是安装了依赖注入的扩展就有依赖注入了,还需要配置开启
ArgumentCountError: Too few arguments to function yzh52521\Task\Mutex\RedisTaskMutex::__construct(), 0 passed in /home/www/app/licc/yqylgzt/vendor/workerman/webman-framework/src/Container.php on line 41 and exactly 1 expected in /home/www/app/licc/yqylgzt/vendor/yzh52521/webman-task/src/Mutex/RedisTaskMutex.php:17 Stack trace:
0 /home/www/app/licc/yqylgzt/vendor/workerman/webman-framework/src/Container.php(41): yzh52521\Task\Mutex\RedisTaskMutex->__construct()
1 /home/www/app/licc/yqylgzt/vendor/workerman/webman-framework/src/support/Container.php(46): Webman\Container->get()
2 /home/www/app/licc/yqylgzt/vendor/yzh52521/webman-task/src/Server.php(516): support\Container::__callStatic()
3 /home/www/app/licc/yqylgzt/vendor/yzh52521/webman-task/src/Server.php(479): yzh52521\Task\Server->getTaskMutex()
4 /home/www/app/licc/yqylgzt/vendor/yzh52521/webman-task/src/Server.php(505): yzh52521\Task\Server->runInSingleton()
5 /home/www/app/licc/yqylgzt/vendor/yzh52521/webman-task/src/Server.php(178): yzh52521\Task\Server->decorateRunnable()
6 /home/www/app/licc/yqylgzt/vendor/yzh52521/webman-task/src/Server.php(550): yzh52521\Task\Server->crontabRun()
7 [internal function]: yzh52521\Task\Server->crontabCreate()
8 /home/www/app/licc/yqylgzt/vendor/yzh52521/webman-task/src/Server.php(123): call_user_func()
9 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Connection/TcpConnection.php(646): yzh52521\Task\Server->onMessage()
10 [internal function]: Workerman\Connection\TcpConnection->baseRead()
11 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()
12 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Worker.php(1629): Workerman\Events\Event->loop()
13 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Worker.php(1423): Workerman\Worker::forkOneWorkerForLinux()
14 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkWorkersForLinux()
15 /home/www/app/licc/yqylgzt/vendor/workerman/workerman/Worker.php(560): Workerman\Worker::forkWorkers()
16 /home/www/app/licc/yqylgzt/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
17 /home/www/app/licc/yqylgzt/start.php(4): support\App::run()
18 {main}