变更
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace Kiri\Server\Abstracts;
|
||||
|
||||
use Exception;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Swoole\Http\Server as HServer;
|
||||
use Swoole\Server;
|
||||
use Kiri\Server\Constant;
|
||||
@@ -32,6 +34,30 @@ trait TraitServer
|
||||
$container->add($name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param array $signal
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onSignal(array $signal): void
|
||||
{
|
||||
pcntl_signal(SIGINT, [$this, 'onSigint']);
|
||||
foreach ($signal as $sig => $value) {
|
||||
if (is_array($value) && is_string($value[0])) {
|
||||
$value[0] = $this->container->get($value[0]);
|
||||
}
|
||||
if (!is_callable($value, true)) {
|
||||
throw new Exception('Register signal callback must can exec.');
|
||||
}
|
||||
pcntl_signal($sig, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user