改名
This commit is contained in:
@@ -64,9 +64,6 @@ class FileChangeCustomProcess extends Command
|
|||||||
$driver = Kiri::getDi()->get(Inotify::class, [$this->dirs, $this]);
|
$driver = Kiri::getDi()->get(Inotify::class, [$this->dirs, $this]);
|
||||||
}
|
}
|
||||||
$make = Barrier::make();
|
$make = Barrier::make();
|
||||||
go(function () {
|
|
||||||
$this->source = proc_open('php ' . APP_PATH . 'kiri.php sw:server restart', [], $this->pipes);
|
|
||||||
});
|
|
||||||
go(function () {
|
go(function () {
|
||||||
$sign = Coroutine::waitSignal(SIGTERM, -1);
|
$sign = Coroutine::waitSignal(SIGTERM, -1);
|
||||||
if ($sign) {
|
if ($sign) {
|
||||||
@@ -74,14 +71,15 @@ class FileChangeCustomProcess extends Command
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
go(function () use ($driver) {
|
go(function () use ($driver) {
|
||||||
$driver->start();
|
$this->source = proc_open('php ' . APP_PATH . 'kiri.php sw:server restart', [], $this->pipes);
|
||||||
|
|
||||||
|
$driver->start(Coroutine::getCid());
|
||||||
});
|
});
|
||||||
Barrier::wait($make);
|
Barrier::wait($make);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $code
|
* @param $code
|
||||||
* @param $message
|
* @param $message
|
||||||
@@ -102,10 +100,9 @@ class FileChangeCustomProcess extends Command
|
|||||||
* 重启
|
* 重启
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function trigger_reload()
|
public function trigger_reload($cid)
|
||||||
{
|
{
|
||||||
Kiri::getDi()->get(Logger::class)->warning('change reload');
|
Kiri::getDi()->get(Logger::class)->warning('change reload');
|
||||||
|
|
||||||
if (is_resource($this->source)) {
|
if (is_resource($this->source)) {
|
||||||
proc_close($this->source);
|
proc_close($this->source);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ class Inotify
|
|||||||
|
|
||||||
private array $watchFiles = [];
|
private array $watchFiles = [];
|
||||||
|
|
||||||
|
|
||||||
|
protected int $cid;
|
||||||
|
|
||||||
const IG_DIR = [APP_PATH . 'commands', APP_PATH . '.git', APP_PATH . '.gitee'];
|
const IG_DIR = [APP_PATH . 'commands', APP_PATH . '.git', APP_PATH . '.gitee'];
|
||||||
|
|
||||||
|
|
||||||
@@ -28,8 +31,9 @@ class Inotify
|
|||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function start()
|
public function start($cid)
|
||||||
{
|
{
|
||||||
|
$this->cid = $cid;
|
||||||
$this->inotify = inotify_init();
|
$this->inotify = inotify_init();
|
||||||
$this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE;
|
$this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE;
|
||||||
foreach ($this->dirs as $dir) {
|
foreach ($this->dirs as $dir) {
|
||||||
@@ -80,7 +84,7 @@ class Inotify
|
|||||||
public function reload()
|
public function reload()
|
||||||
{
|
{
|
||||||
$this->process->isReloading = true;
|
$this->process->isReloading = true;
|
||||||
$this->process->trigger_reload();
|
$this->process->trigger_reload($this->cid);
|
||||||
|
|
||||||
$this->clearWatch();
|
$this->clearWatch();
|
||||||
foreach ($this->dirs as $root) {
|
foreach ($this->dirs as $root) {
|
||||||
|
|||||||
Reference in New Issue
Block a user