改名
This commit is contained in:
@@ -47,20 +47,49 @@ class ServerInotify extends Process
|
|||||||
Event::add($this->inotify, [$this, 'check']);
|
Event::add($this->inotify, [$this, 'check']);
|
||||||
Event::wait();
|
Event::wait();
|
||||||
} else {
|
} else {
|
||||||
Timer::tick(10000, [$this, 'tick']);
|
Timer::tick(1000, [$this, 'tick']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private $md5Map = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function tick()
|
public function tick()
|
||||||
{
|
{
|
||||||
$this->debug('file modify listener.');
|
$this->debug('file modify listener.');
|
||||||
$this->reload();
|
|
||||||
|
$this->loadByDir(APP_PATH . '/app');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $path
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private function loadByDir($path)
|
||||||
|
{
|
||||||
|
$path = rtrim($path, '/');
|
||||||
|
foreach (glob($path . '/*') as $value) {
|
||||||
|
$md5 = md5($value);
|
||||||
|
|
||||||
|
if (is_dir($value)) {
|
||||||
|
$this->loadByDir($value);
|
||||||
|
}
|
||||||
|
if (!isset($this->md5Map[$md5])) {
|
||||||
|
return $this->reload();
|
||||||
|
}
|
||||||
|
if ($this->md5Map[$md5] != filectime($value)) {
|
||||||
|
return $this->reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始监听
|
* 开始监听
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user