Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

feat(daemon-mode): Daemonize Swoole HTTP server #8

Merged
merged 1 commit into from
Oct 7, 2018
Merged

Conversation

k911
Copy link
Owner

@k911 k911 commented Oct 7, 2018

See commands:

$ 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)

@k911 k911 added the kind/feature New feature or request label Oct 7, 2018
@k911 k911 self-assigned this Oct 7, 2018
@k911 k911 mentioned this pull request Oct 7, 2018
19 tasks
@k911 k911 force-pushed the feat/deamon-mode branch 2 times, most recently from 5e3bb3a to 613f0ff Compare October 7, 2018 13:19
@@ -17,6 +17,7 @@
*/
private const SWOOLE_HTTP_SERVER_CONFIGURATION = [
'reactor_count' => 'reactor_num',
'daemonize' => 'daemonize',
Copy link

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.');
Copy link

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.');
Copy link

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
Copy link

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];
Copy link

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)
```
@k911 k911 force-pushed the feat/deamon-mode branch from 613f0ff to 9146641 Compare October 7, 2018 13:38
@@ -0,0 +1,65 @@
<?php
Copy link

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()));
Copy link

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)
{
Copy link

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)
Copy link

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)
{
Copy link

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

@codeclimate
Copy link

codeclimate bot commented Oct 7, 2018

Code Climate has analyzed commit 9146641 and detected 18 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2
Style 4
Clarity 8
Bug Risk 4

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.

@k911 k911 merged commit cef1f3b into develop Oct 7, 2018
@k911 k911 deleted the feat/deamon-mode branch October 7, 2018 13:46
k911 added a commit that referenced this pull request Oct 7, 2018
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)
```
k911 added a commit that referenced this pull request Oct 7, 2018
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)
```
k911 added a commit that referenced this pull request Oct 7, 2018
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)
```
k911 added a commit that referenced this pull request Oct 7, 2018
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)
```
k911 pushed a commit that referenced this pull request Oct 13, 2018
##  (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)
@k911 k911 mentioned this pull request Oct 20, 2018
4 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant