Now that logging is enabled, the logic to autodiscover all system monitors and their active associated tasks is needed to actually get this module working.

The logic should:

  • Use the Symfony plugin system to find all declared system monitors
  • Use the tasks and monitors that are currently active in the system (based on configuration)
  • Allow running these tasks all at once or on a monitor-by-monitor basis
  • Allow running tasks by task group (picked up from the annotations on the plugin)

These options will tie in with drush commands that are already outlined in other issues already in the queue.

Comments

merauluka created an issue. See original summary.

merauluka’s picture

Work has begun on this feature.

Track progress here:
https://git.drupalcode.org/project/system_monitor/compare/8.x-1.x...task...

merauluka’s picture

Here's a first look at this feature. Setting this to Needs Review to kick off tests.

merauluka’s picture

Status: Active » Needs review
merauluka’s picture

StatusFileSize
new33.25 KB

Retrying with fixes to dependency ordering in services file.

merauluka’s picture

StatusFileSize
new33.75 KB

Fixing schema issue.

merauluka’s picture

StatusFileSize
new40.74 KB

Fixing broken tests.

robpowell’s picture

StatusFileSize
new40.5 KB
new1.13 KB

A few code sniffs fixes. Here is the gitlab branch compare,
https://git.drupalcode.org/project/system_monitor/compare/8.x-1.x...task...

robpowell’s picture

What's going on here, why do we have to pass the class name as string?

SystemMonitorTaskManager::__construct()

public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager, LoggerChannelFactoryInterface $logger, SystemMonitorUtility $system_monitor_utility) {
    parent::__construct(
      'Plugin/SystemMonitorTask',
      $namespaces,
      $module_handler,
      'Drupal\system_monitor\SystemMonitorTaskInterface',
      'Drupal\system_monitor\Annotation\SystemMonitorTask');
...
...
merauluka’s picture

@robpowell This is a common practice when extending DefaultPluginManager. See core for examples.

merauluka’s picture

StatusFileSize
new41.02 KB
new541 bytes

Here's another update. I missed adding this to the actual hook_cron function so it would actually attempt to run on cron.
Whoops!

damienmckenna’s picture

Nice work!

+      '#value' => $this->t('Select which tasks to run when this monitor is executed. <em>If nothing is selected then all tasks will be run.</em>'),

I don't think the em tag is necessary here.

// @TODO: Update options once Event logic is in place.

The correct docblock syntax is @todo without the colon.

+      $tasks = $this->systemMonitorUtility->getAvailableTasksByMonitorId($monitor);
+      if (!empty($tasks)) {
+        foreach ($tasks as $task) {

If getAvailableTasksByMonitorId() always returns an array you could skip the if(!empty()) and just go straight to foreach($this->systemMonitorUtility->getAvailableTasksByMonitorId($monitor)), though that is a little long for a single line. :shrug: :)

General notes:

  • A few functions need parameter descriptions.

You should demo this at the next dev team meeting :-)

merauluka’s picture

StatusFileSize
new41.68 KB
new2.63 KB

Made a few updates based on @dmkenna's recommendations.

I did leave the <em> tags because I wanted to add emphasis on that portion of the field description.

Regarding the parameter descriptions, we're going to perform a final sweep of the module prior to cutting a stable tag that will encompass these sorts of clean up efforts (adding more comments, parameter descriptions, additional tests where needed).

  • merauluka committed d94c234 on 8.x-1.x
    Issue #3087826 by merauluka, robpowell, DamienMcKenna: Implement logic...
merauluka’s picture

Status: Needs review » Fixed

Since this issue was more about code review than actually testing functionality, and since this module is still under heavy development, I'm merging this and marking this issue as "Fixed".

Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.