您好,我的workerman運(yùn)行定時發(fā)送email的任務(wù)
每隔一段時間就會出現(xiàn)busy的狀況(大概運(yùn)行20天就會出現(xiàn))
restart后又能在使用20天
我看workerman.log會出現(xiàn)這樣的錯誤
2021-09-23 08:07:07 pid:13187 Worker[13187] process terminated with ERROR: E_ERROR "Uncaught RedisException: read error on connection to localhost:6379 in /var/xxxxxx/autoWriteLog.php
Stack trace:
#0 /var/xxxxxx/autoWriteLog.php(280): Redis->lLen('OrderSe...')
使用的是 use Workerman\Redis\Client;
這是redis連線超時的緣故嗎?
Uncaught RedisException: read error on connection to
這個是redis擴(kuò)展的報錯。
autoWriteLog.php 里的redis實例在onWorkerStart里初始化,不要提前初始化
1 redis鏈接在每個進(jìn)程啟動后鏈接
2 出現(xiàn)redis擴(kuò)展拋出來的異常,丟棄此鏈接,重試獲取鏈接
public static function __callStatic($name, $arguments)
{
try {
return static::$_manager->connection()->{$name}(... $arguments);
} catch (\RedisException $ex) {
Log::info('redis 斷線重連');
try {
static::$_manager->connection()->disconnect();
} catch (\Exception $exception) {
}
self::start(null);//這里在鏈接redis
return static::$_manager->connection()->{$name}(... $arguments);
}
}