Revert "改名"
This reverts commit fdf58326
This commit is contained in:
@@ -23,9 +23,9 @@ use Swoole\WebSocket\Server;
|
||||
defined('DB_ERROR_BUSY') or define('DB_ERROR_BUSY', 'The database is busy. Please try again later.');
|
||||
defined('SELECT_IS_NULL') or define('SELECT_IS_NULL', 'Query data does not exist, please check the relevant conditions.');
|
||||
defined('PARAMS_IS_NULL') or define('PARAMS_IS_NULL', 'Required items cannot be empty, please add.');
|
||||
defined('CONTROLLER_PATH') or define('CONTROLLER_PATH', APP_PATH . 'controllers/');
|
||||
defined('MODEL_PATH') or define('MODEL_PATH', APP_PATH . 'models/');
|
||||
defined('COMPONENT_PATH') or define('COMPONENT_PATH', APP_PATH . 'components/');
|
||||
defined('CONTROLLER_PATH') or define('CONTROLLER_PATH', realpath(APP_PATH . 'controllers/'));
|
||||
defined('MODEL_PATH') or define('MODEL_PATH', realpath(APP_PATH . 'models/'));
|
||||
defined('COMPONENT_PATH') or define('COMPONENT_PATH', realpath(APP_PATH . 'components/'));
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,18 +3,17 @@
|
||||
namespace Kiri\FileListen;
|
||||
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Abstracts\Config;
|
||||
use Kiri\Annotation\Inject;
|
||||
use Kiri\Core\Json;
|
||||
use Kiri\Error\Logger;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri;
|
||||
use Kiri\Annotation\Inject;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Process;
|
||||
use Swoole\Timer;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
@@ -61,7 +60,6 @@ class HotReload extends Command
|
||||
|
||||
/**
|
||||
* @throws ConfigException
|
||||
* @throws \ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function initCore()
|
||||
@@ -198,27 +196,30 @@ class HotReload extends Command
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 重启
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function trigger_reload()
|
||||
public function trigger_reload(string $path = '')
|
||||
{
|
||||
if ($this->int == 1) {
|
||||
return;
|
||||
}
|
||||
$this->int = 1;
|
||||
$this->logger->warning('change reload');
|
||||
|
||||
if (!empty($path) && str_starts_with($path, CONTROLLER_PATH)) {
|
||||
$pid = file_get_contents(storage('.swoole.pid'));
|
||||
if (!empty($pid) && Process::kill($pid, 0)) {
|
||||
Process::kill($pid, SIGUSR1);
|
||||
}
|
||||
} else {
|
||||
$this->stopServer();
|
||||
$this->process = new Process(function (Process $process) {
|
||||
$process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "start"]);
|
||||
});
|
||||
|
||||
$this->process->start();
|
||||
$this->int = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ class Inotify
|
||||
}
|
||||
//非重启类型
|
||||
if (str_ends_with($ev['name'], '.php')) {
|
||||
Timer::after(3000, fn() => $this->reload());
|
||||
Timer::after(3000, fn() => $this->reload($ev['name']));
|
||||
$this->isReloading = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -95,9 +95,9 @@ class Inotify
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function reload()
|
||||
public function reload($path)
|
||||
{
|
||||
$this->process->trigger_reload();
|
||||
$this->process->trigger_reload($path);
|
||||
$this->clearWatch();
|
||||
foreach ($this->dirs as $root) {
|
||||
$this->watch($root);
|
||||
@@ -113,11 +113,7 @@ class Inotify
|
||||
public function clearWatch()
|
||||
{
|
||||
foreach ($this->watchFiles as $wd) {
|
||||
try {
|
||||
@inotify_rm_watch($this->inotify, $wd);
|
||||
} catch (\Throwable $exception) {
|
||||
// logger()->addError($exception->getMessage(), 'throwable');
|
||||
}
|
||||
}
|
||||
$this->watchFiles = [];
|
||||
}
|
||||
|
||||
@@ -106,15 +106,18 @@ class Scaner
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function timerReload()
|
||||
public function timerReload($path)
|
||||
{
|
||||
$this->isReloading = TRUE;
|
||||
$this->process->trigger_reload();
|
||||
|
||||
$this->process->int = -1;
|
||||
if (str_contains($path, CONTROLLER_PATH))
|
||||
|
||||
$this->process->trigger_reload($path);
|
||||
|
||||
$this->loadDirs();
|
||||
|
||||
$this->process->int = -1;
|
||||
|
||||
$this->isReloading = FALSE;
|
||||
$this->process->isReloadingOut = FALSE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user