diff --git a/src/helpers.php b/src/helpers.php index 41d3fcc..aec97b9 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -19,16 +19,32 @@ define('OPTIONS_SUCCESS','success'); define('OPTIONS_ERROR','error'); +/** + * 重启 + * + * @param string $file + * @return void + */ function reload(string $file) { Worker::log($file . ' update and reload. '); - if(extension_loaded('posix') and extension_loaded('pcntl')){ + if (extension_loaded('posix') and extension_loaded('pcntl')) { posix_kill(posix_getppid(), SIGUSR1); - }else{ + } else { Worker::reloadAllWorkers(); } } +/** + * 获取本机ip + * + * @return string + */ +function get_local_ip(): string +{ + return trim(shell_exec('curl -s ifconfig.me')); +} + /** * @param string|null $key * @param mixed|null $default @@ -36,9 +52,9 @@ function reload(string $file) */ function config(string $key = null, $default = null) { - if(Client::$debug) { + if (Client::$debug) { return $default; - }else{ + } else { return \config($key, $default); } } \ No newline at end of file