Skip to content

Instantly share code, notes, and snippets.

@SuneKjaergaard
Last active January 12, 2024 04:01
Show Gist options
  • Save SuneKjaergaard/c686ee5fb2564685148ad03fc87ba219 to your computer and use it in GitHub Desktop.
Save SuneKjaergaard/c686ee5fb2564685148ad03fc87ba219 to your computer and use it in GitHub Desktop.
Small shell script to restart the uWSGI application when https://github.com/unbit/uwsgi/issues/1369 happens. Based on uWSGI server run by upstart
#!/bin/bash
line=$(tail -1 /var/log/myapp/myapp.uwsgi.log)
substr='uWSGI listen queue of socket'
if test "${line#*$substr}" != "$line"
then
#We're using upstart, could be easily adapted to fx systemd
# Adding a log statement to keep track of when this happens. Remember to create the monitor dir
/sbin/initctl restart myapp > /var/log/myapp/monitor/uwsgi-monitor.log 2>&1
echo "$(date) restarted myapp due to listen queue error" >> /var/log/myapp/monitor/uwsgi-monitor.log
fi
@SuneKjaergaard
Copy link
Author

Disclaimer, this will also restart the server in case of higher load than your capacity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment