This commit is contained in:
2021-08-19 16:01:07 +08:00
parent 6fa51c2fe3
commit fb453f674d
5 changed files with 76 additions and 9 deletions
+11 -3
View File
@@ -5,12 +5,12 @@ namespace Kiri\Crontab;
use Exception;
use Server\ServerManager;
use Server\Abstracts\CustomProcess;
use Kiri\Abstracts\Config;
use Kiri\Cache\Redis;
use Kiri\Exception\ConfigException;
use Kiri\Kiri;
use Server\Abstracts\CustomProcess;
use Server\ServerManager;
use Swoole\Process;
use Swoole\Timer;
use Throwable;
@@ -26,6 +26,9 @@ class Zookeeper extends CustomProcess
private int $workerNum = 0;
private int $_timer = -1;
/**
* @param Process $process
* @return string
@@ -47,7 +50,7 @@ class Zookeeper extends CustomProcess
*/
public function onHandler(Process $process): void
{
Timer::tick(300, [$this, 'loop']);
$this->_timer = Timer::tick(300, [$this, 'loop']);
}
@@ -57,6 +60,11 @@ class Zookeeper extends CustomProcess
*/
public function loop()
{
if ($this->isExit()) {
Timer::clear($this->_timer);
$this->exit();
return;
}
$redis = Kiri::app()->getRedis();
defer(fn() => $redis->release());
$range = $this->loadCarobTask($redis);
+4
View File
@@ -49,6 +49,10 @@ class LoggerProcess extends CustomProcess
*/
public function message(Process $process)
{
if ($this->isExit()) {
$this->exit();
return;
}
$message = Json::decode($process->read());
if (!empty($message)) {
Kiri::writeFile($this->getDirName($message), $message[0], FILE_APPEND);
@@ -54,6 +54,15 @@ class FileChangeCustomProcess extends CustomProcess
}
/**
* @param Process $process
*/
public function signListen(Process $process): void
{
}
/**
* @param $code
* @param $message