Skip to content

Overview

This suite schedules jobs using a cron interface. Jobs are disabled by default and can be turned on or off dynamically via API.

The cron suite provides:

  • Logging and metrics
  • Admin page to enable/disable cron jobs and see who holds authority (enabledBy)

Use add-cron-job to add a new cron job to your package. You can also create a new cron package with cron/init.

Package structure and integration

See base, which defines cron jobs. The expected way to integrate these into your service is:

  • Have the monolith run cron jobs as part of its startup process.
  • Add the cron job router to the HTTP express server for administration.
  • Add the cron jobs page to the admin SPA.

Relationship with jobs

The cron service only enqueues jobs on a regular interval. See the jobs package for more details on how to define background jobs in your service and allow cron to enqueue them.

Authority

Enabling a cron job via the admin API records the calling admin's Kratos id in job_settings.enabled_by. From then on, the enqueued job will be run under the authority of that user.

Packages

PackageRoleDocs
@saflib/cron-httpCron scheduler and Express admin routesCode reference · Workflows
@saflib/cron-dbJob settings persistenceCode reference
@saflib/cron-specOpenAPI spec and request typesCode reference
@saflib/cron-vueAdmin SPA pageComponents