Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1643a839b3 | |||
| d4a15d26ed | |||
| 485d926dc0 |
+48
-1
@@ -18,6 +18,7 @@ use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\Kiri;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Server\ServerManager;
|
||||
use Swoole\Process;
|
||||
use Swoole\WebSocket\Server;
|
||||
|
||||
if (!function_exists('make')) {
|
||||
@@ -52,6 +53,38 @@ if (!function_exists('make')) {
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('checkPortIsAlready')) {
|
||||
|
||||
|
||||
/**
|
||||
* @param $port
|
||||
* @return bool|string
|
||||
* @throws Exception
|
||||
*/
|
||||
function checkPortIsAlready($port): bool|string
|
||||
{
|
||||
if (!Kiri::getPlatform()->isLinux()) {
|
||||
exec("lsof -i :" . $port . " | grep -i 'LISTEN' | awk '{print $2}'", $output);
|
||||
if (empty($output)) return false;
|
||||
$output = explode(PHP_EOL, $output[0]);
|
||||
return $output[0];
|
||||
}
|
||||
|
||||
$serverPid = file_get_contents(storage('.swoole.pid'));
|
||||
if (!empty($serverPid) && shell_exec('ps -ef | grep ' . $serverPid . ' | grep -v grep')) {
|
||||
Process::kill($serverPid, SIGTERM);
|
||||
}
|
||||
|
||||
exec('netstat -lnp | grep ' . $port . ' | grep "LISTEN" | awk \'{print $7}\'', $output);
|
||||
if (empty($output)) {
|
||||
return false;
|
||||
}
|
||||
return explode('/', $output[0])[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('done')) {
|
||||
|
||||
/**
|
||||
@@ -59,12 +92,26 @@ if (!function_exists('done')) {
|
||||
*/
|
||||
function done()
|
||||
{
|
||||
ServerManager::setEnv('state', 'exit');
|
||||
set_env('state', 'exit');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('set_env')) {
|
||||
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $value
|
||||
*/
|
||||
function set_env($key, $value)
|
||||
{
|
||||
putenv(sprintf('%s=%s', $key, $value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('enable_file_modification_listening')) {
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ use Kiri\Jwt\Jwt;
|
||||
use Kiri\Kiri;
|
||||
use ReflectionException;
|
||||
use Server\ServerManager;
|
||||
use Server\SInterface\OnTaskInterface;
|
||||
use Server\Contract\OnTaskInterface;
|
||||
use Swoole\Table;
|
||||
|
||||
/**
|
||||
|
||||
@@ -136,7 +136,6 @@ class BaseObject implements Configure
|
||||
$message = print_r($message, true);
|
||||
}
|
||||
$message = "\033[35m[" . date('Y-m-d H:i:s') . '][DEBUG]: ' . $message . "\033[0m";
|
||||
$message .= PHP_EOL;
|
||||
|
||||
$this->logger()->debug(Logger::DEBUG, [$message, $method, $file]);
|
||||
}
|
||||
@@ -154,7 +153,6 @@ class BaseObject implements Configure
|
||||
$message = print_r($message, true);
|
||||
}
|
||||
$message = "\033[34m[" . date('Y-m-d H:i:s') . '][INFO]: ' . $message . "\033[0m";
|
||||
$message .= PHP_EOL;
|
||||
|
||||
$this->logger()->info(Logger::NOTICE, [$message, $method, $file]);
|
||||
}
|
||||
@@ -173,7 +171,6 @@ class BaseObject implements Configure
|
||||
}
|
||||
|
||||
$message = "\033[36m[" . date('Y-m-d H:i:s') . '][SUCCESS]: ' . $message . "\033[0m";
|
||||
$message .= PHP_EOL;
|
||||
|
||||
$this->logger()->notice(Logger::NOTICE, [$message, $method, $file]);
|
||||
}
|
||||
@@ -192,7 +189,6 @@ class BaseObject implements Configure
|
||||
}
|
||||
|
||||
$message = "\033[33m[" . date('Y-m-d H:i:s') . '][WARNING]: ' . $message . "\033[0m";
|
||||
$message .= PHP_EOL;
|
||||
|
||||
$this->logger()->critical(Logger::NOTICE, [$message, $method, $file]);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class GiiTask extends GiiBase
|
||||
|
||||
namespace App\Async;
|
||||
|
||||
use Server\SInterface\OnTaskInterface;
|
||||
use Server\Contract\OnTaskInterface;
|
||||
|
||||
';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user