qqq
This commit is contained in:
@@ -104,8 +104,6 @@ class AsyncServer implements ServerInterface
|
|||||||
{
|
{
|
||||||
$this->server = new $match($config->host, $config->port, $config->mode, $config->socket);
|
$this->server = new $match($config->host, $config->port, $config->mode, $config->socket);
|
||||||
$this->server->set($this->systemConfig($config, $daemon));
|
$this->server->set($this->systemConfig($config, $daemon));
|
||||||
|
|
||||||
Logger::_alert('Listen ' . $config->type . ' address ' . $config->host . '::' . $config->port);
|
|
||||||
if (!isset($config->events[Constant::SHUTDOWN])) {
|
if (!isset($config->events[Constant::SHUTDOWN])) {
|
||||||
$config->events[Constant::SHUTDOWN] = [OnServer::class, 'onShutdown'];
|
$config->events[Constant::SHUTDOWN] = [OnServer::class, 'onShutdown'];
|
||||||
}
|
}
|
||||||
@@ -161,8 +159,6 @@ class AsyncServer implements ServerInterface
|
|||||||
throw new Exception('Listen port fail.' . swoole_last_error());
|
throw new Exception('Listen port fail.' . swoole_last_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::_alert('Listen ' . $config->type . ' address ' . $config->host . '::' . $config->port);
|
|
||||||
|
|
||||||
$port->set($this->resetSettings($config->type, $config->settings));
|
$port->set($this->resetSettings($config->type, $config->settings));
|
||||||
|
|
||||||
$this->onEventListen($port, $config->getEvents());
|
$this->onEventListen($port, $config->getEvents());
|
||||||
|
|||||||
+34
-31
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Kiri\Server\Handler;
|
namespace Kiri\Server\Handler;
|
||||||
|
|
||||||
|
use Kiri\Abstracts\Logger;
|
||||||
use Kiri\Di\Inject\Container;
|
use Kiri\Di\Inject\Container;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
@@ -25,40 +26,42 @@ class OnServer extends Server
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SServer $server
|
* @param SServer $server
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function onStart(SServer $server): void
|
public function onStart(SServer $server): void
|
||||||
{
|
{
|
||||||
\Kiri::setProcessName(sprintf('start[%d].server', $server->master_pid));
|
\Kiri::setProcessName(sprintf('start[%d].server', $server->master_pid));
|
||||||
|
foreach (config('server.ports') as $value) {
|
||||||
event(new OnStart($server));
|
Logger::_alert('Listen ' . $value['type'] . ' address ' . $value['host'] . '::' . $value['port']);
|
||||||
}
|
}
|
||||||
|
event(new OnStart($server));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SServer $server
|
* @param SServer $server
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function onBeforeShutdown(SServer $server): void
|
public function onBeforeShutdown(SServer $server): void
|
||||||
{
|
{
|
||||||
event(new OnBeforeShutdown($server));
|
event(new OnBeforeShutdown($server));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SServer $server
|
* @param SServer $server
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
public function onShutdown(SServer $server): void
|
public function onShutdown(SServer $server): void
|
||||||
{
|
{
|
||||||
@unlink(storage('.swoole.pid'));
|
@unlink(storage('.swoole.pid'));
|
||||||
event(new OnShutdown($server));
|
event(new OnShutdown($server));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user