改名
This commit is contained in:
@@ -77,7 +77,7 @@ class ServerInotify extends Process
|
|||||||
/**
|
/**
|
||||||
* @param $path
|
* @param $path
|
||||||
* @param bool $isReload
|
* @param bool $isReload
|
||||||
* @return void
|
* @return void|mixed
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function loadByDir($path, $isReload = false)
|
private function loadByDir($path, $isReload = false)
|
||||||
@@ -89,29 +89,44 @@ class ServerInotify extends Process
|
|||||||
foreach (glob($path . '/*') as $value) {
|
foreach (glob($path . '/*') as $value) {
|
||||||
if (is_dir($value)) {
|
if (is_dir($value)) {
|
||||||
$this->loadByDir($value, $isReload);
|
$this->loadByDir($value, $isReload);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
$md5 = md5($value);
|
if (is_file($value)) {
|
||||||
$mTime = filectime($value);
|
if ($this->checkFile($value, $isReload)) {
|
||||||
if (!isset($this->md5Map[$md5])) {
|
continue;
|
||||||
if ($isReload) {
|
|
||||||
$this->isReloading = true;
|
|
||||||
return Timer::after(2000, [$this, 'timerReload']);
|
|
||||||
}
|
|
||||||
$this->md5Map[$md5] = $mTime;
|
|
||||||
} else {
|
|
||||||
if ($this->md5Map[$md5] != $mTime) {
|
|
||||||
if ($isReload) {
|
|
||||||
$this->isReloading = true;
|
|
||||||
return Timer::after(2000, [$this, 'timerReload']);
|
|
||||||
}
|
|
||||||
$this->md5Map[$md5] = $mTime;
|
|
||||||
}
|
}
|
||||||
|
$this->timerReload();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $value
|
||||||
|
* @param $isReload
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function checkFile($value, $isReload)
|
||||||
|
{
|
||||||
|
$md5 = md5($value);
|
||||||
|
$mTime = filectime($value);
|
||||||
|
if (!isset($this->md5Map[$md5])) {
|
||||||
|
if ($isReload) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$this->md5Map[$md5] = $mTime;
|
||||||
|
} else {
|
||||||
|
if ($this->md5Map[$md5] != $mTime) {
|
||||||
|
if ($isReload) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$this->md5Map[$md5] = $mTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始监听
|
* 开始监听
|
||||||
*/
|
*/
|
||||||
@@ -176,6 +191,9 @@ class ServerInotify extends Process
|
|||||||
*/
|
*/
|
||||||
public function timerReload()
|
public function timerReload()
|
||||||
{
|
{
|
||||||
|
if ($this->isReloading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->isReloading = true;
|
$this->isReloading = true;
|
||||||
$this->trigger_reload();
|
$this->trigger_reload();
|
||||||
$this->int = -1;
|
$this->int = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user