From c9e510d4fdb74e6efc64b2c66e3975fdec4ed11f Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 19 Sep 2020 20:28:01 +0200 Subject: [PATCH] Use getmypid() as dependency (improve testing) --- src/Core/Process.php | 4 ++-- src/Core/Worker.php | 2 +- static/dependencies.config.php | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Core/Process.php b/src/Core/Process.php index 08284b211b..f8958f102c 100644 --- a/src/Core/Process.php +++ b/src/Core/Process.php @@ -67,14 +67,14 @@ class Process */ private $pid; - public function __construct(LoggerInterface $logger, App\Mode $mode, IConfig $config, Model\Process $processModel, string $basepath) + public function __construct(LoggerInterface $logger, App\Mode $mode, IConfig $config, Model\Process $processModel, string $basepath, int $pid) { $this->logger = $logger; $this->mode = $mode; $this->config = $config; $this->basePath = $basepath; $this->processModel = $processModel; - $this->pid = getmypid(); + $this->pid = $pid; } /** diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 80ec16982c..c586310b7e 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -1172,7 +1172,7 @@ class Worker $args = ['no_cron' => !$do_cron]; $a = DI::app(); - $process = new Core\Process(DI::logger(), DI::mode(), DI::config(), $a->getBasePath()); + $process = new Core\Process(DI::logger(), DI::mode(), DI::config(), DI::modelProcess(), $a->getBasePath(), getmypid()); $process->run($command, $args); // after spawning we have to remove the flag. diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 3df54b79e6..b1a54786ac 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -187,6 +187,7 @@ return [ Process::class => [ 'constructParams' => [ [Dice::INSTANCE => '$basepath'], + getmypid(), ], ], App\Router::class => [