diff --git a/docker/entrypoint-collector.sh b/docker/entrypoint-collector.sh index 501c8d5..c94a67b 100755 --- a/docker/entrypoint-collector.sh +++ b/docker/entrypoint-collector.sh @@ -5,6 +5,10 @@ printenv | sed 's/^\(.*\)$/export \1/g' > /env.sh +# adding ability to customize the cron schedule. +SCRUTINY_COLLECTOR_CRON_SCHEDULE=${SCRUTINY_COLLECTOR_CRON_SCHEDULE:-"0 0 * * *"} +sed -i 's|{SCRUTINY_COLLECTOR_CRON_SCHEDULE}|'"${SCRUTINY_COLLECTOR_CRON_SCHEDULE}"'|g' /etc/cron.d/scrutiny + # now that we have the env start cron in the foreground echo "starting cron" su -c "cron -l 8 -f" root diff --git a/rootfs/etc/cont-init.d/50-config b/rootfs/etc/cont-init.d/50-config new file mode 100644 index 0000000..3c7cece --- /dev/null +++ b/rootfs/etc/cont-init.d/50-config @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash + +SCRUTINY_COLLECTOR_CRON_SCHEDULE=${SCRUTINY_COLLECTOR_CRON_SCHEDULE:-"0 0 * * *"} +sed -i 's|{SCRUTINY_COLLECTOR_CRON_SCHEDULE}|'"${SCRUTINY_COLLECTOR_CRON_SCHEDULE}"'|g' /etc/cron.d/scrutiny \ No newline at end of file diff --git a/rootfs/etc/cron.d/scrutiny b/rootfs/etc/cron.d/scrutiny index f464d04..9571f4b 100644 --- a/rootfs/etc/cron.d/scrutiny +++ b/rootfs/etc/cron.d/scrutiny @@ -11,5 +11,5 @@ MAILTO="" # correctly route collector logs (STDOUT & STDERR) to Cron foreground (collectable by Docker STDOUT) # cron schedule to run daily at midnight: '0 0 * * *' # System environmental variables are stripped by cron, source our dump of the docker environmental variables before each command (/env.sh) -0 0 * * * root . /env.sh; /scrutiny/bin/scrutiny-collector-metrics run >/proc/1/fd/1 2>/proc/1/fd/2 +{SCRUTINY_COLLECTOR_CRON_SCHEDULE} root . /env.sh; /scrutiny/bin/scrutiny-collector-metrics run >/proc/1/fd/1 2>/proc/1/fd/2 # An empty line is required at the end of this file for a valid cron file.