# cron-control-runner **Repository Path**: mirrors_Automattic/cron-control-runner ## Basic Information - **Project Name**: cron-control-runner - **Description**: Go-based runner for Cron Control - **Primary Language**: Unknown - **License**: GPL-2.0 - **Default Branch**: trunk - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-11-14 - **Last Updated**: 2026-09-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Cron Control Runner A Go-based runner for processing WordPress cron events, via [Cron Control](https://github.com/Automattic/Cron-Control) interfaces. ## Installation & Usage 1. Clone the repo, and cd into the repo directory. 1. Build the binary for the target machine, example: `GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o bin/cron-control-runner main.go` 1. Optionally move the binary to where you want it. 1. Run it! ``` cron-control-runner -debug -wp-path="/var/www/html" -wp-cli-path="/usr/local/bin/wp" ``` ### Development If you would just like to test the runner locally, can do a simpler process and even feed it mock data: ``` cd path/to/cloned/repo/cron-control-runner go run . -use-mock-data -debug ``` Another option for a more realistic test environment is provided via docker: 1. Build the binary as usual (see [Installation & Usage](#installation--usage)) Make sure it's at the specified location (`bin/cron-control-runner` & built with the specified target params). 1. `docker-compose up` This will spin up a clean WordPress instance and kick off an [intialization script](./bin/docker-init.sh) on the CLI container which culminates in cron-control-runner listening for connections on the host os at the usual port (`21222`). It's helpful to specify some environment variables (e.g. in an `.env` file): * You can specify the image for the cli container via the `BATCH_IMAGE_NAME` environment variable. By default, `wordpress:cli` is used. * You can specify the `remoteToken` value via the `WP_CLI_TOKEN` environment variable. ## Runner Options - `-debug` - enables debug mode (extra logging) - `-wp-cli-path` string - path to WP-CLI binary (default "/usr/local/bin/wp"). Must be directly executable: remote mode runs it as-is. The non-FPM performer runs a PHP entry point (a phar or script with a php shebang, or a file starting with ` ...` with an opcache file cache under the OS temp dir (`cron-control-runner-opcache`). Each short-lived process then loads precompiled opcodes from disk instead of recompiling WordPress and every plugin on each call, which roughly halves the cost of a `list-due-batch` on a large codebase. Timestamp validation stays on, so changed files are recompiled automatically; the directory can simply be left to the container's lifetime. The runner exits at startup if it cannot create that directory, since php refuses to start with `opcache.file_cache_only=1` and no usable cache dir. ### metrics & logger Helpers for logging and tracking metrics. ### remote Functionality supporting the Remote WP CLI feature. This went mostly untouched in the latest refactor, aside from a few globals variable tweaking and linting fixes. Perhaps could take another look later down the road into cleaning up / refactoring this piece. But for now, it's preferable to not move this stone at the same time. ## Metrics If you enable the metrics system and endpoint by providing the `-prom-metrics-address` arg, then you will get the following metrics for performance monitoring: ``` cron_control_runner_get_sites_latency_seconds_bucket{status="success|failure",le="..."} cron_control_runner_get_sites_latency_seconds_count{status="success|failure"} cron_control_runner_get_sites_latency_seconds_sum{status="success|failure"} cron_control_runner_get_site_events_events_received_total{site="https://your.site.url"} cron_control_runner_get_site_events_latency_seconds_bucket{site="https://your.site.url",status="success|failure",le="..."} cron_control_runner_get_site_events_latency_seconds_count{site="https://your.site.url",status="success|failure"} cron_control_runner_get_site_events_latency_seconds_sum{site="https://your.site.url",status="success|failure"} cron_control_runner_run_event_latency_seconds_bucket{reason="ok|error",site_url="https://your.site.url",status="success|failure",le="..."} cron_control_runner_run_event_latency_seconds_count{reason="ok|error",site_url="https://your.site.url",status="success|failure"} cron_control_runner_run_event_latency_seconds_sum{reason="ok|error",site_url="https://your.site.url",status="success|failure"} cron_control_runner_run_worker_all_busy_hits cron_control_runner_run_worker_busy_pct cron_control_runner_run_worker_state_count{state="busy"} cron_control_runner_run_worker_state_count{state="idle"} cron_control_runner_run_worker_state_count{state="max"} cron_control_runner_wpcli_call_duration_seconds_bucket{command="cron-control orchestrate runner-only run|...",backend="fpm|cli",status="success|error",le="..."} cron_control_runner_wpcli_call_duration_seconds_count{command="...",backend="fpm|cli",status="success|error"} cron_control_runner_wpcli_call_duration_seconds_sum{command="...",backend="fpm|cli",status="success|error"} ```