diff --git a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php index c3d9a9853c..06a01d2256 100644 --- a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php +++ b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php @@ -108,27 +108,8 @@ function (HookData $hook) use ($integration, $server, $scheme) { public function instrumentWorkerStart(callable $callback, SwooleIntegration $integration, Server $server) { - if ($server->mode === SWOOLE_BASE) { - return; - } - - \DDTrace\install_hook( - $callback, - function (HookData $hook) use ($integration, $server) { - handle_fork(); - } - ); - } - - public function instrumentWorkerStop(callable $callback, SwooleIntegration $integration, Server $server) - { - if ($server->mode === SWOOLE_BASE) { - return; - } - \DDTrace\install_hook( $callback, - null, function (HookData $hook) use ($integration, $server) { handle_fork(); } @@ -151,9 +132,7 @@ public function init(): int '__construct', null, function ($server) use ($integration) { - foreach (['workerstart', 'workerstop', 'workerexit', 'workererror'] as $serverEvent) { - $server->on($serverEvent, function () { }); - } + $server->on('workerstart', function () { }); } ); @@ -176,11 +155,6 @@ function ($server, $scope, $args, $retval) use ($integration) { case 'workerstart': $integration->instrumentWorkerStart($callback, $integration, $server); break; - case 'workerstop': - case 'workerexit': - case 'workererror': - $integration->instrumentWorkerStop($callback, $integration, $server); - break; } } diff --git a/tests/Frameworks/Swoole/index.php b/tests/Frameworks/Swoole/index.php index 9018f79782..3eb0a4e914 100644 --- a/tests/Frameworks/Swoole/index.php +++ b/tests/Frameworks/Swoole/index.php @@ -3,7 +3,9 @@ require __DIR__ . '/../../vendor/autoload.php'; $http = new Swoole\Http\Server("0.0.0.0", 9999); - +$http->set([ + 'worker_num' => 2 +]); $http->on('request', function ($request, $response) { $requestUri = $request->server['request_uri']; diff --git a/tests/Sapi/SwooleServer/SwooleServer.php b/tests/Sapi/SwooleServer/SwooleServer.php index ca41ae5554..15e0c29a45 100644 --- a/tests/Sapi/SwooleServer/SwooleServer.php +++ b/tests/Sapi/SwooleServer/SwooleServer.php @@ -73,7 +73,7 @@ public function start() public function stop() { error_log("[swoole-server] Stopping..."); - $this->process->stop(0); + $this->process->stop(0, SIGTERM); } public function isFastCgi()