-
-
Notifications
You must be signed in to change notification settings - Fork 47
feat(daemon-mode): Daemonize Swoole HTTP server #8
Conversation
5e3bb3a
to
613f0ff
Compare
@@ -17,6 +17,7 @@ | |||
*/ | |||
private const SWOOLE_HTTP_SERVER_CONFIGURATION = [ | |||
'reactor_count' => 'reactor_num', | |||
'daemonize' => 'daemonize', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define a constant instead of duplicating this literal "daemonize" 5 times.
} elseif ($this->isRunningInBackground()) { | ||
Process::kill($this->configuration->getPid(), 15); // SIGTERM | ||
} else { | ||
throw new RuntimeException('Swoole HTTP Server has not been running.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define and throw a dedicated exception instead of using a generic one.
} elseif ($this->isRunningInBackground()) { | ||
Process::kill($this->configuration->getPid(), 10); // SIGUSR1 | ||
} else { | ||
throw new RuntimeException('Swoole HTTP Server has not been running.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define and throw a dedicated exception instead of using a generic one.
@@ -0,0 +1,65 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
*/ | ||
public function daemonize(?string $pidFile = null): void | ||
{ | ||
$settings = ['daemonize' => true]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename "$settings" which has the same name as the field declared at line 46.
See commands: ```bash $ bin/console swoole:server:start # starts swoole http server in background $ bin/console swoole:server:stop # stops swoole http server running in background $ bin/console swoole:server:reload # reloads swoole http server's workers and project classes (not infrastructure/vendor ones) ```
@@ -0,0 +1,65 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
protected function startServer(HttpServerConfiguration $serverConfiguration, HttpServer $server, SymfonyStyle $io): void | ||
{ | ||
if (!$serverConfiguration->existsPidFile() && !\touch($serverConfiguration->getPidFile())) { | ||
throw new RuntimeException(\sprintf('Could not create pid file "%s".', $serverConfiguration->getPid())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define and throw a dedicated exception instead of using a generic one.
HttpServer $server, | ||
HttpServerConfiguration $serverConfiguration, | ||
ParameterBagInterface $parameterBag) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
public function __construct( | ||
HttpServer $server, | ||
HttpServerConfiguration $serverConfiguration, | ||
ParameterBagInterface $parameterBag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The closing parenthesis of a multi-line function declaration must be on a new line
HttpServer $server, | ||
HttpServerConfiguration $serverConfiguration, | ||
ParameterBagInterface $parameterBag) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Code Climate has analyzed commit 9146641 and detected 18 issues on this pull request. Here's the issue category breakdown:
Note: there is 1 critical issue. The test coverage on the diff in this pull request is 1.7% (50% is the threshold). This pull request will bring the total coverage in the repository to 9.1% (-1.3% change). View more on Code Climate. |
See commands: ```bash $ bin/console swoole:server:start # starts swoole http server in background $ bin/console swoole:server:stop # stops swoole http server running in background $ bin/console swoole:server:reload # reloads swoole http server's workers and project classes (not infrastructure/vendor ones) ```
See commands: ```bash $ bin/console swoole:server:start # starts swoole http server in background $ bin/console swoole:server:stop # stops swoole http server running in background $ bin/console swoole:server:reload # reloads swoole http server's workers and project classes (not infrastructure/vendor ones) ```
See commands: ```bash $ bin/console swoole:server:start # starts swoole http server in background $ bin/console swoole:server:stop # stops swoole http server running in background $ bin/console swoole:server:reload # reloads swoole http server's workers and project classes (not infrastructure/vendor ones) ```
See commands: ```bash $ bin/console swoole:server:start # starts swoole http server in background $ bin/console swoole:server:stop # stops swoole http server running in background $ bin/console swoole:server:reload # reloads swoole http server's workers and project classes (not infrastructure/vendor ones) ```
## (2018-10-13) * fix(io): Properly close stdout/stderr ([94041e6](94041e6)) * chore(debug): Add symfony/var-dumper package ([e67f1c5](e67f1c5)) * chore(dev-branch): Set develop as 0.3.x-dev branch ([ccad089](ccad089)) * test(component): Test AtomicCounter component ([d8649f2](d8649f2)) * test(server): Test WithRequestHandlerConfigurator ([f73246d](f73246d)) * refactor(configurator): Remove useless configurator ([1c6111e](1c6111e)) * feat(daemon-mode): Daemonize Swoole HTTP server (#8) ([3cca5c4](3cca5c4)), closes [#8](#8)
See commands: