Skip to content

Commit 6ebed2e

Browse files
author
Benjamin Calef
committed
[v0.1.4] handle sigint and sigterm, change method to public
1 parent cb81395 commit 6ebed2e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Model/Processor/ForkedProcessor.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public function __construct(
4444
$this->itemProvider = $itemProvider;
4545
$this->callback = $callback;
4646
$this->maxChildrenProcess = $maxChildrenProcess;
47-
pcntl_signal(SIGINT, [$this, 'handleSigInt']);
47+
pcntl_signal(SIGINT, [$this, 'handleSig']);
48+
pcntl_signal(SIGTERM, [$this, 'handleSig']);
4849
}
4950

5051
public function process(): void
@@ -58,6 +59,11 @@ public function process(): void
5859
}
5960
}
6061

62+
public function handleSig(): void
63+
{
64+
$this->running = false;
65+
}
66+
6167
private function handleSingleChildProcesses(): void
6268
{
6369
$currentPage = 1;
@@ -227,11 +233,6 @@ private function processChild(int $currentPage, int $totalPages, int $childProce
227233
]);
228234
}
229235

230-
private function handleSigInt(): void
231-
{
232-
$this->running = false;
233-
}
234-
235236
private function getMemoryUsage(): string
236237
{
237238
return round(memory_get_usage(true) / (1024 * 1024), 2) . 'MB';

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "zepgram/module-multi-threading",
33
"description": "This module is a powerful tool for developers who want to process large data sets in a short amount of time",
44
"type": "magento2-module",
5-
"version": "0.1.3",
5+
"version": "0.1.4",
66
"authors": [
77
{
88
"name": "Benjamin Calef",

0 commit comments

Comments
 (0)