Skip to content

Commit

Permalink
Merge pull request #79 from genhoi/pcntl_async_signals
Browse files Browse the repository at this point in the history
Use pcntl_async_signals for php >=7.1
  • Loading branch information
prolic authored Feb 4, 2020
2 parents 210f4f2 + d99588f commit 348f152
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 19 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ sudo: required
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
Expand All @@ -30,7 +29,6 @@ cache:

before_script:
- mkdir -p "$HOME/.php-cs-fixer"
- if [ $TRAVIS_PHP_VERSION = "7.0" ]; then phpenv config-rm xdebug.ini; fi
- sudo cp $TRAVIS_BUILD_DIR/provision/rabbitmq.config /etc/rabbitmq/
- sudo service rabbitmq-server restart
- git clone https://github.com/alanxz/rabbitmq-c.git
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": "~7.0",
"php": "^7.1",
"beberlei/assert": "^2.4 || ^3.0",
"marc-mabe/php-enum": "^2.2 || ^3.0",
"psr/log": "^1.0"
Expand Down
10 changes: 0 additions & 10 deletions src/AbstractConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ abstract class AbstractConsumer implements Consumer
*/
protected $errorCallback;

/**
* @var bool
*/
protected $usePcntlSignalDispatch = false;

/**
* Start consumer
*
Expand Down Expand Up @@ -165,11 +160,6 @@ public function consume(int $msgAmount = 0)
$this->ackOrNackBlock();
}

if ($this->usePcntlSignalDispatch) {
// Check for signals
pcntl_signal_dispatch();
}

if (! $this->keepAlive || (0 !== $this->target && $this->countMessagesConsumed >= $this->target)) {
$this->ackOrNackBlock();
$this->shutdown();
Expand Down
4 changes: 1 addition & 3 deletions src/CallbackConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public function __construct(
}

if (extension_loaded('pcntl')) {
declare(ticks=1);

$this->usePcntlSignalDispatch = true;
pcntl_async_signals(true);

pcntl_signal(SIGTERM, [$this, 'shutdown']);
pcntl_signal(SIGINT, [$this, 'shutdown']);
Expand Down
4 changes: 1 addition & 3 deletions src/JsonRpc/JsonRpcServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ public function __construct(
}

if (extension_loaded('pcntl')) {
declare(ticks=1);

$this->usePcntlSignalDispatch = true;
pcntl_async_signals(true);

pcntl_signal(SIGTERM, [$this, 'shutdown']);
pcntl_signal(SIGINT, [$this, 'shutdown']);
Expand Down

0 comments on commit 348f152

Please sign in to comment.