🐛 Fixed issues with incremental indexer command#561
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #561 +/- ##
============================================
- Coverage 57.24% 56.99% -0.25%
- Complexity 1391 1396 +5
============================================
Files 340 340
Lines 5669 5697 +28
============================================
+ Hits 3245 3247 +2
- Misses 2424 2450 +26 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| private function sleep(int $milliseconds): void | ||
| { | ||
| $interval = 100; // check every 100 ms | ||
| $elapsed = 0; | ||
|
|
||
| while ($elapsed < $milliseconds) | ||
| { | ||
| if ($this->cancelled) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| usleep($interval * 1000); | ||
| $elapsed += $interval; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
@pushrbx Is this hack specific to docker containers?
There was a problem hiding this comment.
Also, would it make sense to move this to helpers?
There was a problem hiding this comment.
I just wanted to have a sleep function which can be cancelled. Anytime you cancel the process, it should gracefully exit.
There was a problem hiding this comment.
I'll move this to helpers.
| private function sleep(int $milliseconds): void | ||
| { | ||
| $interval = 100; // check every 100 ms | ||
| $elapsed = 0; | ||
|
|
||
| while ($elapsed < $milliseconds) | ||
| { | ||
| if ($this->cancelled) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| usleep($interval * 1000); | ||
| $elapsed += $interval; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Also, would it make sense to move this to helpers?
|
|
||
| while ($elapsed < $milliseconds) | ||
| { | ||
| if ($this->cancelled) |
There was a problem hiding this comment.
Should we return 1 and use $log->fail() instead?
https://laravel.com/docs/11.x/artisan#exit-codes
There was a problem hiding this comment.
Both of us are wrong. https://tldp.org/LDP/abs/html/exitcodes.html
This should be 128 + {the signal received}
|
closing this in favour of #569 |

The command had several issues. Also interestingly signal trapping doesn't work in lumen projects, so I had to add a hack.