Drupal worker

Druker moves a server's cron schedule out of crontab and into Drupal. Jobs are edited in the admin UI, where anyone who needs to can see them, and a small Go worker beside the site runs them. The worker asks Drupal what its machine should run, runs it, and asks again every refresh, so a change takes effect without a deploy or a restart.

Features

  • Schedules: cron expressions, shortcuts like @daily, and plain English ("every 5 minutes"). Intervals cron cannot express (every 25 seconds, every 90), anchored to the clock, with an optional offset. One-time jobs, remembered across restarts.
  • Servers: a job runs on every server, or only on the ones it names. Servers are config, so production, staging and a laptop each say in settings.php which ones are real.
  • Running: Drush commands (PHP through php:script), or shell command lines once the site allows them ($settings['druker_allow_shell']). A job can wait for another, block the others or run beside them, and never overlaps itself unless it allows it. A job can be switched off without being deleted.
  • Waking: the site, or drush druker:wake, asks the worker to run a job now. It starts within a second or two, so a job no longer has to run every few seconds just to catch the moments work arrives.
  • Seeing it: a dashboard with a card per server and an hour-by-hour view of the day, showing first what will not run.de> reports the same from a terminal.
  • The worker: one static Go binary with no dependencies. It logs to stdout as text or JSON. A refresh never stops a running job. On SIGTERM, running jobs get a grace period, then their whole process group is stopped.
  • From code: add jobs with CollectJobsEvent, and wake one with the druker.wake service.

Need help using or extending this module?

    Vallic
  • Hire the project maintainers: Vallic offers Drupal development and su Drupal hosting.
  • Community support: Use the issue queue.

Post-installation

  1. Go to Configuration → System → Druker. Add a Server for each machine, with the hostname that machine reports. With a single machine, you can skip this: a job with no server runs on every machine.
  2. Add Cron Jobs: a Drush command, without drush, and when to run it. cron is a good first j
  3. Build the worker into the project root, the directory that holds vendor/: cd web/modules/contrib/druker/worker && go build -o /path/to/project/druker . Check it with ./druker -dry-run, then run it as the site's user: under systemd (the README has a unit
    file), as a container platform's worker, or by hand.

Administer Druker jobs and servers is a restricted permission: each job is a command that runs as the web user.

Requirements

Drupal 11 or 12, and Drush on every server that runs the worker. Go 1.23 or later, only where the worker is built: it uses nothing outside the standard library. No other modules or PHP libraries.

Recommended modules

  • Advanced Queue: it holds the queues, and Druker runs their processors, as interval jobs that may overlap.
  • Klaxon: alerts when jobs stop running. Its checks can run as a Druker job instea

Similar projects

  • Ultimate Cron schedules hook_cron implementations inside a cron request. Druker runs any command, outside a request and per server, and Drupal's cron becomes one of its jobs.
  • A plain crontab works, but nobody can see it, keeping servers different means editing each by hand, and every change is a deploy.

    Documentation

    The README covers the JSON contract between Drupal and the worker, the worker's flags, running several environments, and adding or waki

Supporting organizations: 
Development

Project information

Releases