dd_id_d22f855f28
3. App Technical
CronJobs
Table of Contents
Overview
- CronJobs are defined in the
cron_jobstable. - The app runs a check once per minute and executes due jobs via CronJob service subclasses.
- Runner endpoint:
POST /api/cron/run.
Conceptual
Concept
- The app runs scheduled jobs defined in the database.
- Only active jobs that are due are executed.
- Jobs are removed from the
cron_jobstable after a successful run.
Table
cron_jobs.nameidentifies the job and maps to a CronJob subclass.cron_jobs.job_typemaps to the CronJob subclass.cron_jobs.user_idlinks a job to a specific user (when applicable).cron_jobs.run_atdefines one-time schedules.cron_jobs.interval_minutesdefines recurring schedules.cron_jobs.is_activeenables/disables a job.cron_jobs.last_run_attracks the last execution time.- After a job runs successfully, its record is deleted from
cron_jobs.
Implementation
- BE cron runner:
server/var_www/symfony_be/public/index.php(/api/cron/run) - CronJob runner service:
server/var_www/symfony_be/src/Service/CronJob/CronJobRunner.php - CronJob interface:
server/var_www/symfony_be/src/Service/CronJob/CronJobInterface.php - Example job:
server/var_www/symfony_be/src/Service/CronJob/NoopCronJob.php - Reset token invalidation job:
server/var_www/symfony_be/src/Service/CronJob/InvalidateResetPasswordCode.php - Pending registration invalidation job:
server/var_www/symfony_be/src/Service/CronJob/InvalidatePendingRegistration.php - Server cron runner script:
server/var_www/scripts_server/cron_runner.py(calls/api/cron/run) - Tests status cronjob script:
server/var_www/scripts_server/tests_cronjob_runner.py(writesfreshness/all_tests_cronjob_fresh.html).
Tables
table_cron_jobs.md(cron_jobs, schema details live there)table_users.md(users, relation viauser_id)
Services
service_be_php.mdservice_db.md
Routes
route_api_cron_run.md
Schedule
- Cron job (server):
* * * * * /usr/bin/python3 /var/www/scripts_server/cron_runner.py - Tests status cronjob (server):
* * * * * /usr/bin/python3 /var/www/scripts_server/tests_cronjob_runner.py - Freshness watchdog (server):
* * * * * /usr/bin/python3 /var/www/scripts_server/notify_stale_jobs.py