diff --git a/Cargo.lock b/Cargo.lock index 9dee118..3e790e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2217,7 +2217,7 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "reminder-rs" -version = "1.6.17-1" +version = "1.6.18" dependencies = [ "base64 0.21.2", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 2b0f977..e298f88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reminder-rs" -version = "1.6.17-1" +version = "1.6.18" authors = ["Jude Southworth "] edition = "2021" license = "AGPL-3.0 only" @@ -44,6 +44,8 @@ assets = [ ["conf/Rocket.toml", "etc/reminder-rs/Rocket.toml", "600"], ["web/static/**/*", "lib/reminder-rs/static", "644"], ["web/templates/**/*", "lib/reminder-rs/templates", "644"], + ["healthcheck", "lib/reminder-rs/healthcheck", "755"], + ["cron.d/reminder_health", "etc/cron.d/reminder_health", "644"], # ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"] ] conf-files = [ diff --git a/conf/default.env b/conf/default.env index 1a7f2c7..e2d774e 100644 --- a/conf/default.env +++ b/conf/default.env @@ -14,3 +14,5 @@ REMIND_INTERVAL= OAUTH2_DISCORD_CALLBACK= OAUTH2_CLIENT_ID= OAUTH2_CLIENT_SECRET= + +REPORT_EMAIL= diff --git a/cron.d/reminder_health b/cron.d/reminder_health new file mode 100644 index 0000000..27fedef --- /dev/null +++ b/cron.d/reminder_health @@ -0,0 +1 @@ +*/10 * * * * reminders /lib/reminder-rs/healthcheck diff --git a/healthcheck b/healthcheck new file mode 100755 index 0000000..cede199 --- /dev/null +++ b/healthcheck @@ -0,0 +1,10 @@ +#!/bin/bash + +export $(grep -v '^#' /etc/reminder-rs/config.env | xargs -d '\n') + +VAR=$(mysql -N -D reminders -e "SELECT COUNT(1) FROM reminders WHERE utc_time < NOW() - INTERVAL 10 MINUTE AND enabled = 1") + +if [ "$VAR" -gt 0 ] +then + echo "This is to inform that there is a reminder backlog which must be resolved." | mail -s "Backlog: $VAR" "$REPORT_EMAIL" +fi