modify
This commit is contained in:
@@ -39,10 +39,22 @@ class Consumer extends Process
|
|||||||
go(function () {
|
go(function () {
|
||||||
$this->popChannel();
|
$this->popChannel();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->recovery();
|
||||||
$this->tick($process);
|
$this->tick($process);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function recovery()
|
||||||
|
{
|
||||||
|
$redis = redis()->hGetAll('crontab:wait:execute');
|
||||||
|
foreach ($redis as $redi) {
|
||||||
|
$this->channel->push($redi);
|
||||||
|
}
|
||||||
|
fire(Event::SYSTEM_RESOURCE_RELEASES);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@@ -59,7 +71,7 @@ class Consumer extends Process
|
|||||||
Consumer::addTask($crontab);
|
Consumer::addTask($crontab);
|
||||||
}
|
}
|
||||||
} catch (\Throwable $throwable) {
|
} catch (\Throwable $throwable) {
|
||||||
logger()->addError($throwable,'throwable');
|
logger()->addError($throwable, 'throwable');
|
||||||
} finally {
|
} finally {
|
||||||
fire(Event::SYSTEM_RESOURCE_RELEASES);
|
fire(Event::SYSTEM_RESOURCE_RELEASES);
|
||||||
}
|
}
|
||||||
@@ -82,7 +94,9 @@ class Consumer extends Process
|
|||||||
|
|
||||||
$redis = Snowflake::app()->getRedis();
|
$redis = Snowflake::app()->getRedis();
|
||||||
|
|
||||||
|
/** @var Crontab $crontab */
|
||||||
$crontab = swoole_unserialize($redis->get($value));
|
$crontab = swoole_unserialize($redis->get($value));
|
||||||
|
$redis->hSet('crontab:wait:execute', $crontab->getName(), $redis->get($value));
|
||||||
$redis->del($value);
|
$redis->del($value);
|
||||||
if (is_object($crontab)) {
|
if (is_object($crontab)) {
|
||||||
$this->channel->push($crontab);
|
$this->channel->push($crontab);
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ class Crontab extends BaseObject
|
|||||||
public function execute(): void
|
public function execute(): void
|
||||||
{
|
{
|
||||||
$params = call_user_func($this->handler, $this->params, $this->name);
|
$params = call_user_func($this->handler, $this->params, $this->name);
|
||||||
|
\redis()->hDel('crontab:wait:execute', $this->getName());
|
||||||
if ($params !== null) {
|
if ($params !== null) {
|
||||||
$name = date('Y_m_d_H_i_s.' . $this->name . '.log');
|
$name = date('Y_m_d_H_i_s.' . $this->name . '.log');
|
||||||
write(storage($name, '/log/crontab'), serialize($params));
|
write(storage($name, '/log/crontab'), serialize($params));
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class ZookeeperProcess extends Process
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user