diff --git a/README.md b/README.md index a543ef33..dc10f19f 100755 --- a/README.md +++ b/README.md @@ -166,15 +166,13 @@ define('APP_NAMES', [ ]); // 启动前处理,比如加载.env -$beforeFunc = function () { - try { - if (\Swoolefy\Core\SystemEnv::isDevEnv()) { - LoadEnv::load('192.168.25.53:8848','swoolefy','pwa-test','nacos','nacos'); - } - }catch (\Throwable $throwable) { - - } -}; +//$beforeFunc = function () { +// try { +// \Test\LoadEnv::load('192.168.1.101:8848','swoolefy','test','nacos-test','123456'); +// }catch (\Throwable $exception) { +// +// } +//}; include __DIR__.'/swoolefy'; diff --git a/autoloader.php b/autoloader.php index e398d008..4ac88e99 100644 --- a/autoloader.php +++ b/autoloader.php @@ -69,4 +69,4 @@ public static function register(bool $prepend = false) // include file autoloader::register(); // include constants -include ROOT_PATH.'/Config/constants.php'; \ No newline at end of file +include APP_PATH.'/Config/constants.php'; \ No newline at end of file diff --git a/src/Cmd/BaseCmd.php b/src/Cmd/BaseCmd.php index 577c7912..70428392 100644 --- a/src/Cmd/BaseCmd.php +++ b/src/Cmd/BaseCmd.php @@ -121,10 +121,10 @@ protected function beforeInputOptions() */ protected function initCheck(InputInterface $input, OutputInterface $output) { - $appName = $input->getArgument('app_name'); if (version_compare(phpversion(), '7.3.0', '<')) { fmtPrintError("php version must >= 7.3.0, current php version = " . phpversion()); } + if (version_compare(swoole_version(), '4.8.5', '<')) { fmtPrintError("the swoole version must >= 4.8.5, current swoole version = " . swoole_version()); } @@ -132,6 +132,7 @@ protected function initCheck(InputInterface $input, OutputInterface $output) if (function_exists('apc_clear_cache')) { apc_clear_cache(); } + if (function_exists('opcache_reset')) { opcache_reset(); } @@ -277,7 +278,7 @@ protected function makeDirLogAndPid(array &$config) } if (!isset($config['app_conf'])) { - fmtPrintError(APP_NAME . "/Protocol/conf.php" . " must include app_conf file and set app_conf"); + fmtPrintError(APP_NAME . '/Protocol/conf.php must include app_conf file and set app_conf'); exit(0); } } diff --git a/src/Cmd/MonitorCmd.php b/src/Cmd/MonitorCmd.php index 6bd3633d..e975b00b 100644 --- a/src/Cmd/MonitorCmd.php +++ b/src/Cmd/MonitorCmd.php @@ -18,8 +18,8 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $selfScript = $_SERVER['argv'][0]; - $appName = $input->getArgument('app_name'); - $pidFile = $this->getPidFile($appName); + $appName = $input->getArgument('app_name'); + $pidFile = $this->getPidFile($appName); // 人为执行stop命令后,会删除pidFile,防止监控不断重启进程。只有异常情况下的进程停止,pidFile会存在,不被删除,然后会监控判断是否需要重启 if (!is_file($pidFile)) { fmtPrintError("Pid file={$pidFile} is not exist, please check server weather is running"); diff --git a/src/Cmd/RestartCmd.php b/src/Cmd/RestartCmd.php index b4112bfc..3629cb6e 100644 --- a/src/Cmd/RestartCmd.php +++ b/src/Cmd/RestartCmd.php @@ -23,10 +23,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $force = $input->getOption('force'); $lineValue = ""; if (empty($force)) { - if (!isWorkerService()) { - $lineValue = initConsoleStyleIo()->ask( "1、你确定 【重启】 应用【{$appName}】? (yes or no)"); - } else { + if (SystemEnv::isWorkerService()) { $lineValue = initConsoleStyleIo()->ask( "1、你确定 【重启】 workerService【" . WORKER_SERVICE_NAME . "】? (yes or no)"); + } else { + $lineValue = initConsoleStyleIo()->ask( "1、你确定 【重启】 应用【{$appName}】? (yes or no)"); } } diff --git a/src/Cmd/SendCmd.php b/src/Cmd/SendCmd.php index 2323c420..511b815d 100644 --- a/src/Cmd/SendCmd.php +++ b/src/Cmd/SendCmd.php @@ -21,10 +21,10 @@ protected function execute(InputInterface $input, OutputInterface $output) return 0; } - $appName = $input->getArgument('app_name'); + $appName = $input->getArgument('app_name'); $processName = getenv('name'); - $action = getenv('action'); - $msg = getenv('msg'); + $action = getenv('action'); + $msg = getenv('msg'); if (empty($msg)) { $msg = ''; } diff --git a/src/Cmd/StopCmd.php b/src/Cmd/StopCmd.php index c7be00e1..63048583 100644 --- a/src/Cmd/StopCmd.php +++ b/src/Cmd/StopCmd.php @@ -21,24 +21,24 @@ protected function execute(InputInterface $input, OutputInterface $output) $force = $input->getOption('force'); $lineValue = ""; if (empty($force)) { - if (!isWorkerService()) { - $lineValue = initConsoleStyleIo()->ask( "1、你确定停止应用【{$appName}】? (yes or no)"); + if (SystemEnv::isWorkerService()) { + $lineValue = initConsoleStyleIo()->ask( "1、你确定 [停止] workerService【" . WORKER_SERVICE_NAME . "】? (yes or no)"); } else { - $lineValue = initConsoleStyleIo()->ask( "1、你确定停止workerService【" . WORKER_SERVICE_NAME . "】? (yes or no)"); + $lineValue = initConsoleStyleIo()->ask( "1、你确定 [停止] 应用【{$appName}】? (yes or no)"); } } if (strtolower($lineValue) == 'yes' || $force) { - if (!isWorkerService()) { - $this->commonStop($appName); - } else { + if (SystemEnv::isWorkerService()) { $this->workerStop($appName); + } else { + $this->commonStop($appName); } } else { - if (!isWorkerService()) { - fmtPrintInfo("\n你已放弃停止应用{$appName},应用继续running中"); + if (SystemEnv::isWorkerService()) { + fmtPrintInfo(PHP_EOL."你已放弃停止workerService【" . WORKER_SERVICE_NAME . "】,应用继续running中"); } else { - fmtPrintInfo("\n你已放弃停止workerService【" . WORKER_SERVICE_NAME . "】,应用继续running中"); + fmtPrintInfo(PHP_EOL."你已放弃停止应用{$appName},应用继续running中"); } exit(0); } diff --git a/src/Stubs/swag.php b/src/Stubs/swag.php index a361d896..37731ba9 100644 --- a/src/Stubs/swag.php +++ b/src/Stubs/swag.php @@ -8,16 +8,12 @@ exit("【Error】missing source dir\n"); } -defined('ROOT_PATH') or define('ROOT_PATH', __DIR__); -// 启动目录 -defined('START_DIR_ROOT') or define('START_DIR_ROOT', __DIR__); - // 启动目录 defined('START_DIR_ROOT') or define('START_DIR_ROOT', __DIR__); // 应用父目录 defined('ROOT_PATH') or define('ROOT_PATH', __DIR__); -// 应用目录 -defined('APP_PATH') or define('APP_PATH', __DIR__.'/'.ucfirst($_SERVER['argv'][2])); +// 应用目录(此处获取的$_SERVER['argv'][1]) +defined('APP_PATH') or define('APP_PATH', __DIR__.'/'.ucfirst($_SERVER['argv'][1])); registerNamespace(APP_PATH);