Alternative/generic async recurring tasks runner module

Created on 4 September 2023, over 1 year ago

I was looking for something similar, based on https://mglaman.dev/blog/using-reactphp-run-drupal-tasks. In my case I wanted to be able to run arbitrary tasks, not only the Advanced Queue processor. So, I've created https://www.drupal.org/project/recurring_task which has some features more than advancedqueue_runner:

  • It allows to run any PHP code file, not only drush advancedqueue:queue:process. You can configure any Drush or non-Drush file tHat executes PHP.
  • You can create, not only one, but as many runners as you need. Each runner is able to run a different command on different interval
  • Configured commands and their command line params support two tokens: [drupal:root] for the absolute path to the Drupal webtoot and [drupal:url] for the site's base URL.
  • Each runner can be debugged, retrieving valuable information in the Drupal log, when the runner is in debug mode.
  • Each runner can be configured to auto-start on cron after a severe failure, such as server reboot or services restart.
  • Each runner has an string ID, a label, and an optional description. They are config entities.
  • The start/stop logic of each runner is exposed on the runner config entity interface, for instance:
    // Define a recurring task that rebuilds the cache each 5 minutes.
    $runner = RecurringTaskRunner::create(
      'id' => 'cache_rebuild',
      'label' => 'Cache rebuild',
      'command' => '[drupal:root]/../vendor/bin/drush',
      'params' => 'cache:rebuild',
      'interval' => 300,
      'auto_restart' => TRUE,
    );
    $runner->save();
    
    $runner->start();
    // OR
    $runner->stop();
    
  • It exposes a UI to manage runners, their settings and the ability to start/stop them.

Future planned improvements:

  • Drush command to start/stop a specific runner
  • Relying on PHP posix/pcntl extensions when they are available instead of using the exec() command.
  • Test the runner (this seems not to be an easy task)

This module makes advancedqueue_runner obsolete as is very easy to create a task that runs drush advancedqueue:queue:process. Please consider deprecating this module and let's join forces to maintain the other, more generic module. At least I would be very happy if you can give it a try.

🌱 Plan
Status

Active

Version

2.0

Component

Miscellaneous

Created by

🇷🇴Romania claudiu.cristea Arad 🇷🇴

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024