diff --git a/Inotify.php b/Inotify.php index 7518e5e..a2bb444 100644 --- a/Inotify.php +++ b/Inotify.php @@ -51,16 +51,15 @@ class Inotify extends BaseProcess set_exception_handler([$this, 'error']); if (!extension_loaded('inotify')) { - Timer::tick(1000, function ($cid) { + while (true) { if ($this->isStop()) { - Timer::clear($cid); + break; } - }); + sleep(1); + } return; } - - $this->dirs = Config::get('inotify', []); - + $this->dirs = Config::get('reload.inotify', []); $this->start(); } diff --git a/ServerCommand.php b/ServerCommand.php index 43e239a..c22e2e2 100644 --- a/ServerCommand.php +++ b/ServerCommand.php @@ -24,67 +24,67 @@ class ServerCommand extends Command { - const ACTIONS = ['start', 'stop', 'restart']; + const ACTIONS = ['start', 'stop', 'restart']; - /** - * - */ - protected function configure() - { - $this->setName('sw:server') - ->setDescription('server start|stop|reload|restart') - ->addArgument('action', InputArgument::OPTIONAL, 'run action', 'start') - ->addOption('daemon', 'd', InputOption::VALUE_OPTIONAL, 'is run daemonize'); - } + /** + * + */ + protected function configure() + { + $this->setName('sw:server') + ->setDescription('server start|stop|reload|restart') + ->addArgument('action', InputArgument::OPTIONAL, 'run action', 'start') + ->addOption('daemon', 'd', InputOption::VALUE_OPTIONAL, 'is run daemonize'); + } - /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int - * @throws ConfigException - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface - * @throws \ReflectionException - * @throws Exception - */ - public function execute(InputInterface $input, OutputInterface $output): int - { - $manager = Kiri::app()->getServer(); - $manager->setDaemon((int)!is_null($input->getOption('daemon'))); + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + * @throws ConfigException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws \ReflectionException + * @throws Exception + */ + public function execute(InputInterface $input, OutputInterface $output): int + { + $manager = Kiri::app()->getServer(); + $manager->setDaemon((int)!is_null($input->getOption('daemon'))); - $this->scan_file(); + $this->scan_file(); - $action = $input->getArgument('action'); - if (is_null($action)) { - throw new Exception('I don\'t know what I want to do.'); - } - if (!in_array($action, self::ACTIONS)) { - throw new Exception('I don\'t know what I want to do.'); - } - if ($action == 'restart' || $action == 'stop') { - $manager->shutdown(); - if ($action == 'stop') { - return 1; - } - } - $manager->start(); - return 1; - } + $action = $input->getArgument('action'); + if (is_null($action)) { + throw new Exception('I don\'t know what I want to do.'); + } + if (!in_array($action, self::ACTIONS)) { + throw new Exception('I don\'t know what I want to do.'); + } + if ($action == 'restart' || $action == 'stop') { + $manager->shutdown(); + if ($action == 'stop') { + return 1; + } + } + $manager->start(); + return 1; + } - /** - * @return void - * @throws ConfigException - * @throws \ReflectionException - */ - protected function scan_file() - { - $config = Config::get('scanner', []); - if (is_array($config)) foreach ($config as $key => $value) { - scan_directory($value, $key); - } - } + /** + * @return void + * @throws ConfigException + * @throws \ReflectionException + */ + protected function scan_file(): void + { + $config = Config::get('reload.scanner', []); + if (is_array($config)) foreach ($config as $key => $value) { + scan_directory($value, $key); + } + } }