改名
This commit is contained in:
+2
-1
@@ -137,8 +137,9 @@ class Server extends HttpService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
* @return \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
||||||
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
#[Pure] public function getServer(): \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
public function getServer(): \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
||||||
{
|
{
|
||||||
return $this->manager->getServer();
|
return $this->manager->getServer();
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-7
@@ -4,12 +4,13 @@ declare(strict_types=1);
|
|||||||
namespace Server;
|
namespace Server;
|
||||||
|
|
||||||
|
|
||||||
|
use Note\Inject;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
use Note\Inject;
|
use Server\Events\OnServerBeforeStart;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
@@ -63,12 +64,12 @@ class ServerCommand extends Command
|
|||||||
if (!in_array($input->getArgument('action'), self::ACTIONS)) {
|
if (!in_array($input->getArgument('action'), self::ACTIONS)) {
|
||||||
throw new Exception('I don\'t know what I want to do.');
|
throw new Exception('I don\'t know what I want to do.');
|
||||||
}
|
}
|
||||||
$action = $input->getArgument('action');
|
if ($manager->isRunner() && $input->getArgument('action') == 'start') {
|
||||||
if ($action == 'stop' || $action == 'restart') {
|
throw new Exception('Service is running. Please use restart.');
|
||||||
$manager->shutdown();
|
|
||||||
if ($action == 'stop') {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
$manager->shutdown();
|
||||||
|
if ($input->getArgument('action') == 'stop') {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return $this->generate_runtime_builder($manager);
|
return $this->generate_runtime_builder($manager);
|
||||||
}
|
}
|
||||||
@@ -86,7 +87,7 @@ class ServerCommand extends Command
|
|||||||
Coroutine::set([
|
Coroutine::set([
|
||||||
'hook_flags' => SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_BLOCKING_FUNCTION,
|
'hook_flags' => SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_BLOCKING_FUNCTION,
|
||||||
'enable_deadlock_check' => FALSE,
|
'enable_deadlock_check' => FALSE,
|
||||||
'exit_condition' => static function () {
|
'exit_condition' => function () {
|
||||||
return Coroutine::stats()['coroutine_num'] === 0;
|
return Coroutine::stats()['coroutine_num'] === 0;
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user