qqq
This commit is contained in:
@@ -42,39 +42,16 @@ class AsyncServer implements ServerInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function initCoreServers(array $service, int $daemon = 0): void
|
||||
{
|
||||
$this->listener($service, $daemon);
|
||||
$this->initProcess();
|
||||
$this->onSignal();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $service
|
||||
* @param $daemon
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
private function listener(array $service, $daemon): void
|
||||
{
|
||||
$service = $this->genConfigService($service);
|
||||
$this->createBaseServer(array_pop($service), $daemon);
|
||||
foreach ($service as $value) {
|
||||
if (is_null($this->server)) {
|
||||
$this->createBaseServer($value, $daemon);
|
||||
} else {
|
||||
$this->addListener($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function initProcess(): void
|
||||
{
|
||||
foreach ($this->_process as $process) {
|
||||
$this->server->addProcess($process);
|
||||
}
|
||||
on(OnServerBeforeStart::class, [$this, 'onSignal']);
|
||||
}
|
||||
|
||||
|
||||
@@ -189,21 +166,6 @@ class AsyncServer implements ServerInterface
|
||||
$this->onEventListen($port, $config->getEvents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $no
|
||||
* @param array $signInfo
|
||||
* @return void
|
||||
*/
|
||||
public function onSigint($no, array $signInfo): void
|
||||
{
|
||||
try {
|
||||
Logger::_alert('Pid ' . getmypid() . ' get signo ' . $no);
|
||||
$this->shutdown();
|
||||
} catch (\Throwable $exception) {
|
||||
error($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Kiri\Server\Abstracts;
|
||||
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Abstracts\Logger;
|
||||
use ReflectionException;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Http\Server as HServer;
|
||||
@@ -78,6 +79,22 @@ trait TraitServer
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $no
|
||||
* @param array $signInfo
|
||||
* @return void
|
||||
*/
|
||||
public function onSigint($no, array $signInfo): void
|
||||
{
|
||||
try {
|
||||
Logger::_alert('Pid ' . getmypid() . ' get signo ' . $no);
|
||||
$this->shutdown();
|
||||
} catch (\Throwable $exception) {
|
||||
error($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $signal
|
||||
* @param $callback
|
||||
|
||||
@@ -68,7 +68,6 @@ class Server
|
||||
on(OnWorkerStop::class, [Timer::class, 'clearAll'], 9999);
|
||||
on(OnWorkerStart::class, [$this, 'setWorkerName']);
|
||||
on(OnTaskerStart::class, [$this, 'setTaskerName']);
|
||||
|
||||
if (\config('reload.hot') === false) {
|
||||
$this->router->scan_build_route();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user