Skip to content

Commit

Permalink
Remove getStatus method on MasterProcess
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed Sep 27, 2024
1 parent 7fa8a91 commit 0c669c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/Internal/MasterProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function __construct(
$this->pidFile = $pidFile ?? \sprintf('%s/phpss%s.pid', $runDirectory, \hash('xxh32', $this->startFile));
$this->socketFile = \sprintf('%s/phpss%s.socket', $runDirectory, \hash('xxh32', $this->startFile . 'rx'));

$this->supervisor = new Supervisor($this, $stopTimeout);
$this->supervisor = new Supervisor($this, $stopTimeout, $this->status);
$this->scheduler = new Scheduler();
$this->container = new ArrayContainer();
}
Expand Down Expand Up @@ -128,6 +128,10 @@ public function run(bool $daemonize = false): int
$this->status = Status::STARTING;
$this->saveMasterPid();
$this->start();
$this->supervisor->start($this->suspension);
$this->scheduler->start($this->logger, $this->suspension, function () {
return $this->status;
});
$this->status = Status::RUNNING;
$this->logger->info(Server::NAME . ' has started');

Expand Down Expand Up @@ -315,11 +319,6 @@ public function isRunning(): bool
return (0 !== $pid = $this->getPid()) && \posix_kill($pid, 0);
}

public function getStatus(): Status
{
return $this->status;
}

private function free(): void
{
unset($this->plugins);
Expand Down
3 changes: 2 additions & 1 deletion src/Internal/Supervisor/Supervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ final class Supervisor
public function __construct(
private readonly MasterProcess $masterProcess,
private readonly int $stopTimeout,
private Status &$status,
) {
$this->workerPool = new WorkerPool();
}
Expand Down Expand Up @@ -121,7 +122,7 @@ private function onChildStop(int $pid, int $exitCode): void
$this->masterProcess->dispatch(new Killed($pid));
});

switch (($this->masterProcess->getStatus())) {
switch ($this->status) {
case Status::RUNNING:
match ($exitCode) {
0 => $this->logger->info(\sprintf('Worker %s[pid:%d] exit with code %s', $worker->getName(), $pid, $exitCode)),
Expand Down

0 comments on commit 0c669c2

Please sign in to comment.