Periodically request data from a specified resource.
My specific use case is for calling a cron.php
resource for a
REDCap instance running
inside a Kubernetes
container. I've been running this for the past 40+ days with no problems,
so I decided to clean it up and release this in the hopes that others would
find it useful.
This is primarily intended to be used inside a container orchestration
environment, therefore all configuration is done through environmental
variables. A liveness
probe
is also supported with the /health
path and the TCP network address
defined by CRON_LISTEN. All output is sent to stdout
for
easy monitoring with Kubernetes tools.
Once I get my helm chart cleaned up, I'll add a repository for it to make deploying easy.
By default, the docker container runs with a UID of 1002, and GID of 1003 (I semi-randomly picked those numbers), but should run fine with any UID/GID combination.
Required.
The URL to be periodically called. Example:
CRON_URL="http://www.example.com:80/cron.php"
Required.
CRON Expression that is accepted by https://godoc.org/github.com/robfig/cron. To have an HTTP GET call be made every minute, use:
CRON_SCHEDULE="@every 1m"
Optional.
HTTP GET accept header sent to CRON_URL, the default is:
CRON_ACCEPT="*/*"
To request only JSON output, the following would be appropriate:
CRON_ACCEPT="application/json"
Optional.
HTTP GET timeout, in milliseconds. Default:
CRON_TIMEOUT="5000"
Required.
TCP network address to listen on for health check. The path is /health
. To listen on localhost port 8000, use:
CRON_LISTEN="127.0.0.1:8000"
With this, a call to http://127.0.0.1:8000/health
should return a HTTP
response status code of 200.