Skip to content

Commit

Permalink
KOJO-242 | Process group awareness
Browse files Browse the repository at this point in the history
  • Loading branch information
mucha55 committed Sep 13, 2021
1 parent 5aa7668 commit 9dd1ec9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ProcessAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected function _initialize(): ProcessAbstract
$this->_getApmNewRelic()->endTransaction();
$this->_setParentProcessId(posix_getppid());
$this->_setProcessId(posix_getpid());
$this->_setProcessGroupId(posix_getpgrp());

$this->getProcessPoolLoggerMessageMetadataBuilder()->setProcess($this);
if ($this->_hasProcessPool()) {
Expand Down Expand Up @@ -203,6 +204,18 @@ public function getParentProcessId(): int
return $this->_read(self::PROP_PARENT_PROCESS_ID);
}

protected function _setProcessGroupId(int $processGroupId): ProcessAbstract
{
$this->_create(self::PROP_PROCESS_GROUP_ID, $processGroupId);

return $this;
}

public function getProcessGroupId(): int
{
return $this->_read(self::PROP_PROCESS_GROUP_ID);
}

public function setExitCode(int $exitCode): ProcessInterface
{
$this->_create(self::PROP_EXIT_CODE, $exitCode);
Expand Down
3 changes: 3 additions & 0 deletions src/ProcessInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface ProcessInterface extends HandlerInterface
public const PROP_PATH = 'path';
public const PROP_TERMINATION_SIGNAL_NUMBER = 'termination_signal_number';
public const PROP_PROCESS_ID = 'process_id';
public const PROP_PROCESS_GROUP_ID = 'process_group_id';
public const PROP_TYPE_CODE = 'type_code';
public const PROP_UUID = 'uuid';
public const PROP_UUID_MAXIMUM_INTEGER = 'uuid_maximum_integer';
Expand All @@ -29,6 +30,8 @@ public function start(): ProcessInterface;

public function getProcessId(): int;

public function getProcessGroupId(): int;

public function setLogger(LoggerInterface $logger);

public function setThrottle(int $seconds = 0): ProcessInterface;
Expand Down

0 comments on commit 9dd1ec9

Please sign in to comment.