From f9b6a22c9497c4a9c5bdb5fe8884d75b0bd5f00b Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Wed, 24 Jul 2024 07:40:23 +0800 Subject: [PATCH] update install.md with celery restart script --- INSTALL.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index d20724f2..d1440c63 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -420,6 +420,32 @@ Once a week or so it's good to run `remove_orphan_files.sh` to save disk space: 5 4 * * 1 rimu cd /home/rimu/pyfedi && /home/rimu/pyfedi/remove_orphan_files.sh ``` +If celery is hanging occasionally (we're looking into it but it's a hard one to solve), put this script in /etc/cron.hourly: + +``` +#!/bin/bash + +# Define the service to restart +SERVICE="celery.service" + +# Get the load average for the last 1 minute +LOAD=$(awk '{print $1}' /proc/loadavg) + +# Check if the load average is less than 0.1 +if (( $(echo "$LOAD < 0.1" | bc -l) )); then + # Restart the service + systemctl restart $SERVICE + # Log the action + echo "$(date): Load average is $LOAD. Restarted $SERVICE." >> /var/log/restart_service.log +else + # Log that no action was taken + echo "$(date): Load average is $LOAD. No action taken." >> /var/log/restart_service.log +fi + +``` + +Adjust the echo "$LOAD < 0.1" to suit your system. + ### Email Email can be sent either through SMTP or Amazon web services (SES). SES is faster but PieFed does not send much