This commit is contained in:
as2252258@163.com
2021-04-11 15:38:23 +08:00
parent d4b64c3af2
commit 60fa2cb896
3 changed files with 136 additions and 120 deletions
+14
View File
@@ -39,10 +39,22 @@ class Consumer extends Process
go(function () {
$this->popChannel();
});
$this->recovery();
$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
*/
@@ -82,7 +94,9 @@ class Consumer extends Process
$redis = Snowflake::app()->getRedis();
/** @var Crontab $crontab */
$crontab = swoole_unserialize($redis->get($value));
$redis->hSet('crontab:wait:execute', $crontab->getName(), $redis->get($value));
$redis->del($value);
if (is_object($crontab)) {
$this->channel->push($crontab);
+1
View File
@@ -200,6 +200,7 @@ class Crontab extends BaseObject
public function execute(): void
{
$params = call_user_func($this->handler, $this->params, $this->name);
\redis()->hDel('crontab:wait:execute', $this->getName());
if ($params !== null) {
$name = date('Y_m_d_H_i_s.' . $this->name . '.log');
write(storage($name, '/log/crontab'), serialize($params));
+1
View File
@@ -65,6 +65,7 @@ class ZookeeperProcess extends Process
}
/**
* @param string $name
*/