Skip to content

Commit

Permalink
feat: add helper function get_local_ip()
Browse files Browse the repository at this point in the history
  • Loading branch information
chaz6chez committed Aug 22, 2024
1 parent 0ec258b commit 341cffd
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,42 @@
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
* @return array|mixed|null
*/
function config(string $key = null, $default = null)
{
if(Client::$debug) {
if (Client::$debug) {
return $default;
}else{
} else {
return \config($key, $default);
}
}

0 comments on commit 341cffd

Please sign in to comment.