Last active
November 25, 2022 08:08
-
-
Save zioproto/a0617b36f74b6eca11a356045d9d185c to your computer and use it in GitHub Desktop.
Restart Wordpress if it is serving HTTP 500s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import requests | |
from requests.adapters import HTTPAdapter, Retry | |
import os | |
s = requests.Session() | |
retries = Retry(total=5, | |
backoff_factor=0.1, | |
status_forcelist=[ 500, 502, 503, 504 ]) | |
s.mount('https://', HTTPAdapter(max_retries=retries)) | |
r = s.head("https://blog.ninux.org") | |
if r.status_code == 500: | |
os.system("systemctl restart apache2") | |
os.system("systemctl restart mysql") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment