2021-11-03 15:17:52 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Server\Abstracts;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Annotation\Inject;
|
|
|
|
|
use Exception;
|
|
|
|
|
use Kiri\Abstracts\Config;
|
|
|
|
|
use Kiri\Exception\ConfigException;
|
|
|
|
|
use Kiri\Kiri;
|
|
|
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Server
|
|
|
|
|
* @package Server\Abstracts
|
|
|
|
|
*/
|
|
|
|
|
abstract class Server
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var LoggerInterface
|
|
|
|
|
*/
|
|
|
|
|
#[Inject(LoggerInterface::class)]
|
|
|
|
|
public LoggerInterface $logger;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $prefix
|
|
|
|
|
* @throws ConfigException
|
|
|
|
|
*/
|
|
|
|
|
protected function setProcessName($prefix)
|
|
|
|
|
{
|
|
|
|
|
if (Kiri::getPlatform()->isMac()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-11-04 23:58:05 +08:00
|
|
|
$name = '[' . Config::get('id', 'system-service') . ']';
|
2021-11-03 15:17:52 +08:00
|
|
|
if (!empty($prefix)) {
|
|
|
|
|
$name .= '.' . $prefix;
|
|
|
|
|
}
|
|
|
|
|
swoole_set_process_name($name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Server constructor.
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|