Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fixed issues with incremental indexer command #561

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pushrbx
Copy link
Collaborator

@pushrbx pushrbx commented Nov 13, 2024

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

@pushrbx pushrbx requested a review from a team as a code owner November 13, 2024 17:07
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 5.00000% with 38 lines in your changes missing coverage. Please review.

Project coverage is 56.99%. Comparing base (2fa3958) to head (a318f24).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...pp/Console/Commands/Indexer/IncrementalIndexer.php 0.00% 28 Missing ⚠️
app/Support/helpers.php 0.00% 7 Missing ⚠️
app/Providers/AppServiceProvider.php 40.00% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Comment on lines 33 to 49
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;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pushrbx Is this hack specific to docker containers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would it make sense to move this to helpers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to have a sleep function which can be cancelled. Anytime you cancel the process, it should gracefully exit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move this to helpers.

Comment on lines 33 to 49
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;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would it make sense to move this to helpers?

app/Providers/AppServiceProvider.php Show resolved Hide resolved

while ($elapsed < $milliseconds)
{
if ($this->cancelled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return 1 and use $log->fail() instead?
https://laravel.com/docs/11.x/artisan#exit-codes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of us are wrong. https://tldp.org/LDP/abs/html/exitcodes.html
This should be 128 + {the signal received}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to let the parent process know which signal terminated the process.
E.g. in PHPStorm when I stop the run:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants