改名
This commit is contained in:
@@ -10,6 +10,7 @@ namespace Snowflake\Process;
|
|||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Snowflake\Abstracts\Config;
|
||||||
use Snowflake\Exception\ComponentException;
|
use Snowflake\Exception\ComponentException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
use Swoole\Error;
|
use Swoole\Error;
|
||||||
@@ -44,8 +45,10 @@ class ServerInotify extends Process
|
|||||||
$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;
|
||||||
$process->name('event: file change.');
|
$process->name('event: file change.');
|
||||||
|
$this->dirs = Config::get('inotify', false, [APP_PATH]);
|
||||||
$this->watch(APP_PATH);
|
foreach ($this->dirs as $dir) {
|
||||||
|
$this->watch($dir);
|
||||||
|
}
|
||||||
Event::add($this->inotify, [$this, 'check']);
|
Event::add($this->inotify, [$this, 'check']);
|
||||||
Event::wait();
|
Event::wait();
|
||||||
} else {
|
} else {
|
||||||
@@ -168,17 +171,15 @@ class ServerInotify extends Process
|
|||||||
$this->isReloadingOut = FALSE;
|
$this->isReloadingOut = FALSE;
|
||||||
|
|
||||||
$this->loadByDir(APP_PATH . 'app');
|
$this->loadByDir(APP_PATH . 'app');
|
||||||
|
$this->loadByDir(APP_PATH . 'routes');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重启
|
* 重启
|
||||||
* @throws ComponentException
|
|
||||||
*/
|
*/
|
||||||
public function trigger_reload()
|
public function trigger_reload()
|
||||||
{
|
{
|
||||||
/** @var Server $server */
|
Snowflake::reload();
|
||||||
$server = Snowflake::app()->get('server')->getServer();
|
|
||||||
$server->reload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -210,11 +211,10 @@ class ServerInotify extends Process
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $dir
|
* @param $dir
|
||||||
* @param bool $root
|
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function watch($dir, $root = TRUE)
|
public function watch($dir)
|
||||||
{
|
{
|
||||||
//目录不存在
|
//目录不存在
|
||||||
if (!is_dir($dir)) {
|
if (!is_dir($dir)) {
|
||||||
@@ -224,10 +224,6 @@ class ServerInotify extends Process
|
|||||||
if (isset($this->watchFiles[$dir])) {
|
if (isset($this->watchFiles[$dir])) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
//根目录
|
|
||||||
if ($root) {
|
|
||||||
$this->dirs[] = $dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array($dir, [APP_PATH . '/config', APP_PATH . '/commands', APP_PATH . '/.git', APP_PATH . '/.gitee'])) {
|
if (in_array($dir, [APP_PATH . '/config', APP_PATH . '/commands', APP_PATH . '/.git', APP_PATH . '/.gitee'])) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -244,7 +240,7 @@ class ServerInotify extends Process
|
|||||||
$path = $dir . '/' . $f;
|
$path = $dir . '/' . $f;
|
||||||
//递归目录
|
//递归目录
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$this->watch($path, FALSE);
|
$this->watch($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测文件类型
|
//检测文件类型
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use ReflectionException;
|
|||||||
use Snowflake\Abstracts\Config;
|
use Snowflake\Abstracts\Config;
|
||||||
use Snowflake\Core\JSON;
|
use Snowflake\Core\JSON;
|
||||||
use Snowflake\Di\Container;
|
use Snowflake\Di\Container;
|
||||||
|
use Snowflake\Exception\ComponentException;
|
||||||
use Snowflake\Exception\NotFindClassException;
|
use Snowflake\Exception\NotFindClassException;
|
||||||
use Snowflake\Process\Process;
|
use Snowflake\Process\Process;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
@@ -199,7 +200,7 @@ class Snowflake
|
|||||||
*/
|
*/
|
||||||
public static function clearProcessId($worker_pid)
|
public static function clearProcessId($worker_pid)
|
||||||
{
|
{
|
||||||
@unlink(storage("{$worker_pid}.sock",'worker'));
|
@unlink(storage("{$worker_pid}.sock", 'worker'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -316,8 +317,12 @@ class Snowflake
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public static function reload()
|
public static function reload()
|
||||||
{
|
{
|
||||||
|
return Snowflake::app()->server->getServer()->reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user