108 lines
4.5 KiB
PHP
108 lines
4.5 KiB
PHP
<?php
|
|
namespace app\event;
|
|
use think\App;
|
|
class SwooleStart
|
|
{
|
|
protected $context = '';
|
|
const LINE='----------------------------------------------------'.PHP_EOL;
|
|
|
|
public function handle($event): void
|
|
{
|
|
app()->make(SwooleStart::class)->show();
|
|
}
|
|
|
|
public function show()
|
|
{
|
|
$this->opCacheClear();
|
|
$this->context = $this->logo();
|
|
$this->context .= self::LINE;
|
|
$this->displayItem('NAME ', config('version.name'));
|
|
$this->displayItem('kernel version', config('version.version'));
|
|
$this->displayItem('php version', phpversion());
|
|
$this->displayItem('swoole version', phpversion('swoole'));
|
|
$this->displayItem('swoole_loader version', phpversion('swoole_loader'));
|
|
$this->displayItem('thinkphp version', App::VERSION);
|
|
//http配置
|
|
$httpConf = \config("swoole.http");
|
|
$this->displayItem('http host', $httpConf["host"]);
|
|
$this->displayItem('http port', $httpConf["port"]);
|
|
$this->displayItem('http worker_num', $httpConf["worker_num"]);
|
|
//websocket配置
|
|
$this->displayItem('websocket enable', \config("swoole.websocket.enable"));
|
|
//rpc配置
|
|
$rpcConf = \config("swoole.rpc.server");
|
|
$this->displayItem('rpc enable', $rpcConf["enable"]);
|
|
if ($rpcConf["enable"]) {
|
|
$this->displayItem('rpc host', $rpcConf["host"]);
|
|
$this->displayItem('rpc port', $rpcConf["port"]);
|
|
$this->displayItem('rpc worker_num', $rpcConf["worker_num"]);
|
|
}
|
|
//队列配置
|
|
$this->displayItem('queue enable', \config("swoole.queue.enable"));
|
|
|
|
//热更新配置
|
|
$this->displayItem('hot_update enable', (bool)\config("swoole.hot_update.enable"));
|
|
|
|
//debug配置
|
|
$this->displayItem('app_debug enable', (bool)env("APP_DEBUG"));
|
|
|
|
$this->displayItem('time', date('Y-m-d H:i:s'));
|
|
|
|
//打印信息
|
|
echo $this->context;
|
|
}
|
|
|
|
|
|
private function logo()
|
|
{
|
|
return<<<LOGO
|
|
_____ _____ _____ _____
|
|
/\ \ /\ \ /\ \ /\ \
|
|
/::\ \ /::\ \ /::\____\ /::\ \
|
|
\:::\ \ \:::\ \ /:::/ / \:::\ \
|
|
\:::\ \ \:::\ \ /:::/ / \:::\ \
|
|
\:::\ \ \:::\ \ /:::/ / \:::\ \
|
|
\:::\ \ \:::\ \ /:::/____/ \:::\ \
|
|
\:::\ \ /::::\ \ /::::\ \ /::::\ \
|
|
\:::\ \ _____ /::::::\ \ /::::::\____\________ _____ /::::::\ \
|
|
\:::\ \ /\ \ /:::/\:::\ \ /:::/\:::::::::::\ \ /\ \ /:::/\:::\ \
|
|
_______________\:::\____\/::\ /:::/ \:::\____\/:::/ |:::::::::::\____\/::\ /:::/ \:::\____\
|
|
\::::::::::::::::::/ /\:::\ /:::/ \::/ /\::/ |::|~~~|~~~~~ \:::\ /:::/ \::/ /
|
|
\::::::::::::::::/____/ \:::\/:::/ / \/____/ \/____|::| | \:::\/:::/ / \/____/
|
|
\:::\~~~~\~~~~~~ \::::::/ / |::| | \::::::/ /
|
|
\:::\ \ \::::/ / |::| | \::::/ /
|
|
\:::\ \ \::/ / |::| | \::/ /
|
|
\:::\ \ \/____/ |::| | \/____/
|
|
\:::\ \ |::| |
|
|
\:::\____\ \::| |
|
|
\::/ / \:| |
|
|
\/____/ \|___|
|
|
|
|
LOGO;
|
|
}
|
|
|
|
private function displayItem($name, $value)
|
|
{
|
|
if ($value === true) {
|
|
$value = 'true';
|
|
}
|
|
elseif ($value === false) {
|
|
$value = 'false';
|
|
}
|
|
elseif ($value === null) {
|
|
$value = 'null';
|
|
}
|
|
$this->context .= "\e[32m" . str_pad($name, 25, ' ', STR_PAD_RIGHT) .'| '. "\e[34m" . $value . "\e[0m \n";
|
|
$this->context .= self::LINE;
|
|
}
|
|
|
|
private function opCacheClear()
|
|
{
|
|
if (function_exists('apc_clear_cache')) {
|
|
apc_clear_cache();
|
|
}
|
|
if (function_exists('opcache_reset')) {
|
|
opcache_reset();
|
|
}
|
|
}
|
|
} |