1
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Kiri\FileListen;
|
namespace Kiri\FileListen;
|
||||||
|
|
||||||
|
use Annotation\Inject;
|
||||||
use Exception;
|
use Exception;
|
||||||
use JetBrains\PhpStorm\NoReturn;
|
use JetBrains\PhpStorm\NoReturn;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
@@ -32,6 +33,10 @@ class HotReload extends Command
|
|||||||
public int $int = -1;
|
public int $int = -1;
|
||||||
|
|
||||||
|
|
||||||
|
#[Inject(Logger::class)]
|
||||||
|
public Logger $logger;
|
||||||
|
|
||||||
|
|
||||||
private Scaner|Inotify $driver;
|
private Scaner|Inotify $driver;
|
||||||
|
|
||||||
private ?Process $process = NULL;
|
private ?Process $process = NULL;
|
||||||
@@ -91,13 +96,14 @@ class HotReload extends Command
|
|||||||
*/
|
*/
|
||||||
#[NoReturn] public function onSignal($data)
|
#[NoReturn] public function onSignal($data)
|
||||||
{
|
{
|
||||||
var_dump($data);
|
|
||||||
$this->driver->clear();
|
$this->driver->clear();
|
||||||
$pid = file_get_contents(storage('.swoole.pid'));
|
$pid = file_get_contents(storage('.swoole.pid'));
|
||||||
if (!empty($pid) && Process::kill($pid, 0)) {
|
if (!empty($pid) && Process::kill($pid, 0)) {
|
||||||
var_dump(Process::kill($pid, SIGTERM));
|
while (Process::kill($pid, 0)) {
|
||||||
|
Process::kill($pid, SIGTERM);
|
||||||
}
|
}
|
||||||
var_dump('over');
|
}
|
||||||
|
$this->logger->notice('over');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -133,7 +139,6 @@ class HotReload extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重启
|
* 重启
|
||||||
*
|
*
|
||||||
@@ -141,7 +146,7 @@ class HotReload extends Command
|
|||||||
*/
|
*/
|
||||||
public function trigger_reload()
|
public function trigger_reload()
|
||||||
{
|
{
|
||||||
Kiri::getDi()->get(Logger::class)->warning('change reload');
|
$this->logger->notice('change reload');
|
||||||
$pid = file_get_contents(storage('.swoole.pid'));
|
$pid = file_get_contents(storage('.swoole.pid'));
|
||||||
if (!empty($pid) && Process::kill($pid, 0)) {
|
if (!empty($pid) && Process::kill($pid, 0)) {
|
||||||
Process::kill($pid, SIGTERM);
|
Process::kill($pid, SIGTERM);
|
||||||
|
|||||||
Reference in New Issue
Block a user