Skip to content

🐛 Fixed issues with incremental indexer command#561

Closed
pushrbx wants to merge 4 commits intomasterfrom
bugfix/incremental-indexing-1
Closed

🐛 Fixed issues with incremental indexer command#561
pushrbx wants to merge 4 commits intomasterfrom
bugfix/incremental-indexing-1

Conversation

@pushrbx
Copy link
Copy Markdown
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
@codecov
Copy link
Copy Markdown

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 9 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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 thread app/Console/Commands/Indexer/IncrementalIndexer.php
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
Copy Markdown
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?

Comment thread app/Providers/AppServiceProvider.php

while ($elapsed < $milliseconds)
{
if ($this->cancelled)
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@pushrbx
Copy link
Copy Markdown
Collaborator Author

pushrbx commented May 1, 2025

closing this in favour of #569

@pushrbx pushrbx closed this May 1, 2025
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