Skip to content

Commit

Permalink
[v0.1.4] handle sigint and sigterm, change method to public
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Calef committed Oct 16, 2023
1 parent cb81395 commit 6ebed2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions Model/Processor/ForkedProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public function __construct(
$this->itemProvider = $itemProvider;
$this->callback = $callback;
$this->maxChildrenProcess = $maxChildrenProcess;
pcntl_signal(SIGINT, [$this, 'handleSigInt']);
pcntl_signal(SIGINT, [$this, 'handleSig']);
pcntl_signal(SIGTERM, [$this, 'handleSig']);
}

public function process(): void
Expand All @@ -58,6 +59,11 @@ public function process(): void
}
}

public function handleSig(): void
{
$this->running = false;
}

private function handleSingleChildProcesses(): void
{
$currentPage = 1;
Expand Down Expand Up @@ -227,11 +233,6 @@ private function processChild(int $currentPage, int $totalPages, int $childProce
]);
}

private function handleSigInt(): void
{
$this->running = false;
}

private function getMemoryUsage(): string
{
return round(memory_get_usage(true) / (1024 * 1024), 2) . 'MB';
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "zepgram/module-multi-threading",
"description": "This module is a powerful tool for developers who want to process large data sets in a short amount of time",
"type": "magento2-module",
"version": "0.1.3",
"version": "0.1.4",
"authors": [
{
"name": "Benjamin Calef",
Expand Down

0 comments on commit 6ebed2e

Please sign in to comment.