This commit is contained in:
2021-04-07 10:11:12 +08:00
parent f4cbc4b409
commit e4e8f76db1
+16 -55
View File
@@ -35,29 +35,6 @@ class ServerInotify extends Process
private int $int = -1; private int $int = -1;
/**
* @throws Exception
*/
private function loadAnnotation()
{
$annotation = Snowflake::app()->getAnnotation();
$annotation->read(directory('app'), 'App');
}
/**
* @param $workerId
* @throws Exception
*/
public function getLoader($workerId)
{
$annotation = Snowflake::app()->getAnnotation();
$server = Snowflake::app()->getSwoole();
$server->sendMessage($annotation->getLoader(), $workerId);
}
/** /**
* @param \Swoole\Process $process * @param \Swoole\Process $process
* @throws Exception * @throws Exception
@@ -67,17 +44,6 @@ class ServerInotify extends Process
set_error_handler([$this, 'onErrorHandler']); set_error_handler([$this, 'onErrorHandler']);
$this->dirs = Config::get('inotify', [APP_PATH]); $this->dirs = Config::get('inotify', [APP_PATH]);
Coroutine\go(function () use ($process) {
$workerId = $process->read(3);
$annotation = Snowflake::app()->getAnnotation();
$server = Snowflake::app()->getSwoole();
$server->sendMessage($annotation->getLoader(),(int) $workerId);
});
$this->loadAnnotation();
if (extension_loaded('inotify')) { if (extension_loaded('inotify')) {
$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;
@@ -231,16 +197,14 @@ class ServerInotify extends Process
$this->isReloading = true; $this->isReloading = true;
$this->trigger_reload(); $this->trigger_reload();
$this->exit(0); $this->clearWatch();
foreach ($this->dirs as $root) {
// $this->clearWatch(); $this->watch($root);
// foreach ($this->dirs as $root) { }
// $this->watch($root); $this->int = -1;
// } $this->isReloading = FALSE;
// $this->int = -1; $this->isReloadingOut = FALSE;
// $this->isReloading = FALSE; $this->md5Map = [];
// $this->isReloadingOut = FALSE;
// $this->md5Map = [];
} }
/** /**
@@ -251,17 +215,14 @@ class ServerInotify extends Process
$this->isReloading = true; $this->isReloading = true;
$this->trigger_reload(); $this->trigger_reload();
$this->exit(0); $this->int = -1;
//
// $this->loadDirs();
// $this->int = -1;
// $this->isReloading = FALSE;
// $this->loadDirs(); $this->isReloadingOut = FALSE;
//
// $this->isReloading = FALSE; $this->tick();
// $this->isReloadingOut = FALSE;
//
// $this->tick();
} }