Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a26b99dd1e | |||
| 86e4a92ab0 | |||
| ea425bb82d | |||
| ad0154d319 | |||
| edb70d2b9b | |||
| 9f3355cab4 | |||
| 4107b5bb07 |
+1
-1
@@ -30,7 +30,7 @@
|
|||||||
"swiftmailer/swiftmailer": "v6.3.*",
|
"swiftmailer/swiftmailer": "v6.3.*",
|
||||||
"psr/container": "^2.0",
|
"psr/container": "^2.0",
|
||||||
"psr/http-server-middleware": "1.0.1",
|
"psr/http-server-middleware": "1.0.1",
|
||||||
"game-worker/kiri-event": "v1.0",
|
"game-worker/kiri-event": "^v1.0",
|
||||||
"ext-inotify": "*"
|
"ext-inotify": "*"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
|
|
||||||
namespace Kiri\FileListen;
|
namespace Kiri\FileListen;
|
||||||
|
|
||||||
use Note\Inject;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Error\Logger;
|
use Kiri\Error\Logger;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
|
use Note\Inject;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
|
use Swoole\Timer;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
@@ -81,7 +82,8 @@ class HotReload extends Command
|
|||||||
}
|
}
|
||||||
$this->trigger_reload();
|
$this->trigger_reload();
|
||||||
|
|
||||||
var_dump(getmypid());
|
Timer::tick(1000, fn() => $this->healthCheck());
|
||||||
|
|
||||||
Process::signal(SIGTERM, [$this, 'onSignal']);
|
Process::signal(SIGTERM, [$this, 'onSignal']);
|
||||||
Process::signal(SIGKILL, [$this, 'onSignal']);
|
Process::signal(SIGKILL, [$this, 'onSignal']);
|
||||||
|
|
||||||
@@ -90,6 +92,25 @@ class HotReload extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function healthCheck()
|
||||||
|
{
|
||||||
|
$pid = (int)file_get_contents(storage('.swoole.pid'));
|
||||||
|
$this->logger->debug('timer ticker.' . $pid . '.' . Process::kill($pid, 0));
|
||||||
|
if (empty($pid)) {
|
||||||
|
$this->trigger_reload();
|
||||||
|
} else if (!Process::kill($pid, 0)) {
|
||||||
|
if ($this->process && Process::kill($this->process->pid, 0)) {
|
||||||
|
echo 'service is shutdown you need reload.';
|
||||||
|
Process::kill($this->process->pid, -15);
|
||||||
|
}
|
||||||
|
$this->trigger_reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -141,6 +162,8 @@ class HotReload extends Command
|
|||||||
$pid = $this->process?->pid;
|
$pid = $this->process?->pid;
|
||||||
$process = new Process(function (Process $process) {
|
$process = new Process(function (Process $process) {
|
||||||
$process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "restart"]);
|
$process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "restart"]);
|
||||||
|
|
||||||
|
$this->logger->warning('service stop.');
|
||||||
});
|
});
|
||||||
$process->start();
|
$process->start();
|
||||||
if ($pid && Process::kill($pid, 0)) {
|
if ($pid && Process::kill($pid, 0)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user