This commit is contained in:
2021-04-19 14:46:07 +08:00
parent aec2be27f7
commit 13d53115cc
+11 -6
View File
@@ -12,7 +12,10 @@ namespace Snowflake\Process;
use Exception;
use Snowflake\Abstracts\Config;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake;
use Swoole\Coroutine;
use Swoole\Event;
use Swoole\Timer;
@@ -41,11 +44,15 @@ class ServerInotify extends Process
set_error_handler([$this, 'onErrorHandler']);
$this->dirs = Config::get('inotify', [APP_PATH]);
var_dump(extension_loaded('inotify'));
if (extension_loaded('inotify')) {
$this->inotify = inotify_init();
$this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE;
$this->watch(APP_PATH);
foreach ($this->dirs as $dir) {
if (!is_dir($dir)) continue;
$this->watch($dir);
}
Event::add($this->inotify, [$this, 'check']);
Event::wait();
} else {
@@ -192,8 +199,9 @@ class ServerInotify extends Process
$this->trigger_reload();
$this->clearWatch();
$this->watch(APP_PATH);
foreach ($this->dirs as $root) {
$this->watch($root);
}
$this->int = -1;
$this->isReloading = FALSE;
$this->isReloadingOut = FALSE;
@@ -225,9 +233,6 @@ class ServerInotify extends Process
*/
public function trigger_reload()
{
logger()->debug('server reload.');
exec(PHP_BINARY . ' snowflake runtime:builder');
Snowflake::reload();