启用crontab后运行程序报错 ERROR php_swoole_server_rshutdown (ERRNO 503)
- Dominant language
- PHP
- Stars
- 13
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
环境
PHP 7.3.26
swoole 4.6.1
hyperf v2.1.1
配置config\autoload\crontab.php
```php
return [
// 是否开启定时任务
'enable' => true,
];
```
config\autoload\server.php
```php
'settings' => [
...
// Task Worker 数量,根据您的服务器配置而配置适当的数量
'task_worker_num' => 1,
// 因为 `Task` 主要处理无法协程化的方法,所以这里推荐设为 `false`,避免协程下出现数据混淆的情况
'task_enable_coroutine' => false,
],
'callbacks' => [
...
// Task callbacks
Event::ON_TASK => [Hyperf\Framework\Bootstrap\TaskCallback::class, 'onTask'],
Event::ON_FINISH => [Hyperf\Framework\Bootstrap\FinishCallback::class, 'onFinish'],
],
```
运行官方文档示例
```php
logger->info(date('Y-m-d H:i:s', time()));
}
}
```
报错
```php
[2021-02-06 16:51:00 *1514.0] ERROR php_swoole_server_rshutdown (ERRNO 503): Fatal error: Uncaught Swoole\Error: Socket#35 has already been bound to another coroutine#20, writing of the same socket in coroutine#21 at the same time is not allowed in /data/wwwroot/hyperf-api/vendor/symfony/console/Output/StreamOutput.php:76
Stack trace:
#0 /data/wwwroot/hyperf-api/vendor/symfony/console/Output/StreamOutput.php(76): fwrite(Resource id #1632, '\e[32m[DEBUG]\e[3...')
#1 /data/wwwroot/hyperf-api/vendor/symfony/console/Output/Output.php(166): Symfony\Component\Console\Output\StreamOutput->doWrite('\e[32m[DEBUG]\e[3...', true)
#2 /data/wwwroot/hyperf-api/vendor/symfony/console/Output/Output.php(132): Symfony\Component\Console\Output\Output->write(Array, true, 1)
#3 /data/wwwroot/hyperf-api/vendor/hyperf/framework/src/Logger/StdoutLogger.php(138): Symfony\Component\Console\Output\Output->writeln('[DEBUG]log('debug', '[DEBUG]
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.