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

ISSUE-133: Make Hydroponics background processing multi child based #138

Merged
merged 66 commits into from
Feb 8, 2021

Conversation

giancarlobi
Copy link
Collaborator

@giancarlobi giancarlobi commented Jan 14, 2021

A lot of hydroponics improvements. See #133

giancarlobi and others added 30 commits October 1, 2019 14:57
Add schema for strawberryfield_textarea (#72)
Issue-71b: Add schema for strawberryfield_field itself! (#73)
Add second parameter to converter (esmero#102)
See esmero#107
Also moves some logic out of the caller into the call-ee so people like Born Digital can intersect the naming/affect/change and (maybe) use full OCFL. There is a HOOK there 👀 !!
First pass on making getDestinationUri() smarter
Do not over process. Key value == $item_id passed by tracker
Adds a verify Drush command
refactor drush command check for ubuntu
First pass: refresh button and some basic info
Copy link
Member

@DiegoPino DiegoPino left a comment

Choose a reason for hiding this comment

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

@giancarlobi looking great. I added some minor comments on cleanup and may give all another pass to make sure we remove comments/etc.

Also some minor notes on configurations, like making the INTs instead of Strings for time based values

config/schema/strawberryfield.schema.yml Outdated Show resolved Hide resolved
config/schema/strawberryfield.schema.yml Show resolved Hide resolved
src/Commands/HydroponicsMultiDrushCommands.php Outdated Show resolved Hide resolved
src/Form/HydroponicsSettingsForm.php Outdated Show resolved Hide resolved
src/Form/HydroponicsSettingsForm.php Outdated Show resolved Hide resolved
src/StrawberryfieldHydroponicsService.php Outdated Show resolved Hide resolved
$heartbeat_max_delta = $this->getHearbeatMaxDelta();

$running_posix = FALSE;
if ($queuerunner_pid > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

What if $queuerunner_pid is not >0? should we not stop processing and return immediately?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, not clear to me what you mean.

if (extension_loaded('pcntl')) {
$running_posix = posix_kill($queuerunner_pid, SIGTERM);
$running_posix = posix_kill(abs($queuerunner_pid), SIGTERM);
Copy link
Member

Choose a reason for hiding this comment

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

We may want to have a comment somewhere like here https://github.com/esmero/strawberryfield/pull/138/files#diff-f87fbb18e8f039828bd65f2204e85b8a323c7f253f13ea2f5109174060aa3a4eR388 (every time we fetch the PID) explaining that if its negative means it was started? basically explain why you use negatives for tracking PIDS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a more verbose checkRunning result, see if what you mean or not, please

else {
\Drupal::state()->set('hydroponics.queurunner_last_pid', 0);
sleep(1);
return "Successfully cleared pid. Thanks";
Copy link
Member

Choose a reason for hiding this comment

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

This message and the way we return messages here is something I'm not totally convinced of
1.- Messages are not translated.
2.- We depend on a message to define if stopped worked? DO we need a also a status returned? We could use maybe instead a StdClass Object to make sending/returning of data easier like we do for the actual workers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@DiegoPino As for checkRunning, stop function can return an array ['staus'] (TRUE all ok, FALSE for error) and ['message'] with text about result, what do you think?

src/StrawberryfieldHydroponicsService.php Outdated Show resolved Hide resolved
@giancarlobi
Copy link
Collaborator Author

@DiegoPino Thanks, I'll parse everything and make changes as for your notes. Not sure if today, probably tomorrow. Anyway we need a full check before merging, obviously.

@DiegoPino
Copy link
Member

@giancarlobi I see all your changes, this is great!

@giancarlobi
Copy link
Collaborator Author

@giancarlobi I see all your changes, this is great!

@DiegoPino I had some free relaxed time and started to make changes. Some left to solve, I hope later or tomorrow to complete all ... I hope

@DiegoPino
Copy link
Member

@giancarlobi that works! Just for future compatibility its suggested (sorry, its only good practice) to use Drupal\Core\State\StateInterface; instead of use Drupal\Core\State\State; for the use statement and the argument annotations and casting in the functions. That way, in case someone needs to override the container injection with a different class that implements the same interface no code change is needed, just the service. yml. You will notice that we do that for almost everything except for the queue factory, since it extends (silly) a too generic interface that has really no methods at all.

@giancarlobi
Copy link
Collaborator Author

@giancarlobi that works! Just for future compatibility its suggested (sorry, its only good practice) to use Drupal\Core\State\StateInterface; instead of use Drupal\Core\State\State; for the use statement and the argument annotations and casting in the functions. That way, in case someone needs to override the container injection with a different class that implements the same interface no code change is needed, just the service. yml. You will notice that we do that for almost everything except for the queue factory, since it extends (silly) a too generic interface that has really no methods at all.

@DiegoPino i.e. as for \Psr\Log\LoggerInterface ? Thanks for note, I'll try to follow guide lines. Also today I learned something new, friend

@DiegoPino
Copy link
Member

yes! True.

@DiegoPino
Copy link
Member

wonderful!

@DiegoPino
Copy link
Member

@giancarlobi first pass on code/sanity looks good! I need to now test with some data/actions and watch logs. What would you suggest is a good way of making sure all is working correctly? What is the the config equivalent of the old method (the simple one by one)? So I can compare? No rush. I will also do some small Drupal Coding Standard changes afterwards (probably a separate branch) so I do not interrupt your work here because I know you are busy. Basically I will create a RC2 copy branch and merge this against that one with each commit (not a squash) and apply the Coding standard changes (small really) to that one. Let me know if that works for you @giancarlobi. Good work!!

@giancarlobi
Copy link
Collaborator Author

Good morning @DiegoPino

@giancarlobi first pass on code/sanity looks good! I need to now test with some data/actions and watch logs. What would you suggest is a good way of making sure all is working correctly? What is the the config equivalent of the old method (the simple one by one)? So I can compare? No rush.

The config as the old method is using "A single process for all queues" in setting admin/config/archipelago/hydroponics

I will also do some small Drupal Coding Standard changes afterwards (probably a separate branch) so I do not interrupt your work here because I know you are busy. Basically I will create a RC2 copy branch and merge this against that one with each commit (not a squash) and apply the Coding standard changes (small really) to that one. Let me know if that works for you @giancarlobi. Good work!!

Perfect, thanks !!!

@DiegoPino DiegoPino changed the base branch from 1.0.0-RC2 to ISSUE-133 February 8, 2021 18:53
@DiegoPino
Copy link
Member

@giancarlobi merging into a local branch ISSUE-133 to apply tiny Drupal coding standards changes. Will preserve the full commit log! This should be "finally" ready from my part by tomorrow. Thank you again for all your patience friend!

@DiegoPino DiegoPino merged commit c222c3a into esmero:ISSUE-133 Feb 8, 2021
@giancarlobi
Copy link
Collaborator Author

@giancarlobi merging into a local branch ISSUE-133 to apply tiny Drupal coding standards changes. Will preserve the full commit log! This should be "finally" ready from my part by tomorrow. Thank you again for all your patience friend!

@DiegoPino don't worry, I'm happy with this. And thanks for your great work.

@DiegoPino
Copy link
Member

DiegoPino commented Feb 24, 2021

@giancarlobi good morning there! (like 4AM I know).

I'm testing and debugging your code right now and I very much like it! Its very efficient and verbose!! Sorry for the delay on testing but there are too many things on my plate and I really wanted to test this in detail since its core to Archipelago

Right now I'm testing the Mono Command (HydroponicsDrushCommands)

One thing I noticed is that we do not have the security timer anymore. Means it will run into it has no more queue items. I feels its the right thing but thinking of a special use case (Multisite on a smaller server) I would like to add it back as an option (checkbox)
Do you think it is something I can do without breaking anything? Like just adding this back? I feel its not that simple right?

$security_time = 720.0;
$securitytimer = $loop->addTimer(720.0, function ($timer) use ($loop, $timer_ping, $idle_timer, &$done) {
      // Finish all if 720 seconds are reached
      \Drupal::logger('hydroponics')->info("720 seconds passed closing Hydroponics Service");
      $loop->cancelTimer($timer_ping);
      foreach($done as $queue_timer) {
        $loop->cancelTimer($queue_timer);
      }
      \Drupal::state()->set('hydroponics.queurunner_last_pid', 0);
      $loop->cancelTimer($idle_timer);
      $loop->stop();
      }
    );

Or, I should i add an extra time check inside

$idle_timer = $loop->addPeriodicTimer($idle_timer_time, function ($timer) use ($loop, $timer_ping, &$done, &$idle) ?

I may need your wise advice on this.
Thanks a lot!

@giancarlobi
Copy link
Collaborator Author

@DiegoPino Sorry for my silence into Archipelago community, here really busy days, I hope to free me to the end of this week. Don't worry about your delay on this, I know you are really really multi-tasking !!!
About security timer, at first look I think is better add a check into idle_timer than add an extra timer (we have to clear it before close and so on).
We can simply count how many times idle_timer loop is executed and (if enabled into config) close loop when N is reached. More or less time will be N * 60s with current hard coded settings.
Whant do you think?
Take care friend

@DiegoPino
Copy link
Member

DiegoPino commented Feb 24, 2021 via email

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