update install.md with celery restart script

This commit is contained in:
rimu 2024-07-24 07:40:23 +08:00
parent 7b7b0abf17
commit f9b6a22c94

View file

@ -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 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
Email can be sent either through SMTP or Amazon web services (SES). SES is faster but PieFed does not send much Email can be sent either through SMTP or Amazon web services (SES). SES is faster but PieFed does not send much