Skip to content

Commit 94d054e

Browse files
NadiyaSYevhen Miroshnychenko
authored andcommitted
MAGECLOUD-2711: Cron kill during redeploy doesn't work (#352)
* MAGECLOUD-2711: Cron kill during redeploy doesn't work - change $UID to $USER * MAGECLOUD-2711: Cron kill during redeploy doesn't work
1 parent e82a044 commit 94d054e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Process/Deploy/CronProcessKill.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function execute()
4646
try {
4747
$this->logger->info('Trying to kill running cron jobs');
4848

49-
$cronPids = $this->shell->execute('exec pgrep -U "$UID" -f "bin/magento cron:run"');
49+
$cronPids = $this->shell->execute('exec pgrep -U "$(id -u)" -f "bin/magento cron:run"');
5050
foreach ($cronPids as $pid) {
5151
$this->killProcess($pid);
5252
}

src/Test/Unit/Process/Deploy/CronProcessKillTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testExecute()
5454
->method('execute')
5555
->willReturnMap(
5656
[
57-
['exec pgrep -U "$UID" -f "bin/magento cron:run"', [], [111, 222]],
57+
['exec pgrep -U "$(id -u)" -f "bin/magento cron:run"', [], [111, 222]],
5858
["kill 111", [], []],
5959
["kill 222", [], []],
6060
]
@@ -75,7 +75,7 @@ public function testExecuteWithNoRunningCrons()
7575
);
7676
$this->shellMock->expects($this->once())
7777
->method('execute')
78-
->with('exec pgrep -U "$UID" -f "bin/magento cron:run"')
78+
->with('exec pgrep -U "$(id -u)" -f "bin/magento cron:run"')
7979
->willThrowException(new \RuntimeException('return code 1', 1));
8080
$this->process->execute();
8181
}
@@ -90,7 +90,7 @@ public function testExecuteWithError()
9090
->with('Trying to kill running cron jobs');
9191
$this->shellMock->expects($this->once())
9292
->method('execute')
93-
->with('exec pgrep -U "$UID" -f "bin/magento cron:run"')
93+
->with('exec pgrep -U "$(id -u)" -f "bin/magento cron:run"')
9494
->willThrowException(new \RuntimeException('return code 2', 2));
9595
$this->loggerMock->expects($this->once())
9696
->method('warning')
@@ -114,7 +114,7 @@ public function testExecuteWithExeption()
114114
);
115115
$this->shellMock->expects($this->at(0))
116116
->method('execute')
117-
->with('exec pgrep -U "$UID" -f "bin/magento cron:run"')
117+
->with('exec pgrep -U "$(id -u)" -f "bin/magento cron:run"')
118118
->willReturn([111, 222]);
119119
$this->shellMock->expects($this->at(1))
120120
->method('execute')

0 commit comments

Comments
 (0)