diff --git a/templates/docs/python.html b/templates/docs/python.html index be16fdc0..7042121e 100644 --- a/templates/docs/python.html +++ b/templates/docs/python.html @@ -1,8 +1,12 @@
If you are already using the requests library, it's convenient to also use it here:
-# using requests:
-import requests
-requests.get("PING_URL")
+import requests
+
+try:
+ requests.get("PING_URL", timeout=10)
+except requests.RequestException as e:
+ # Log ping failure here...
+ print("Ping failed: %s" % e)
diff --git a/templates/docs/python.md b/templates/docs/python.md
index 14cb63d1..361e7900 100644
--- a/templates/docs/python.md
+++ b/templates/docs/python.md
@@ -3,9 +3,13 @@
If you are already using the requests library, it's convenient to also use it here:
```python
-# using requests:
import requests
-requests.get("PING_URL")
+
+try:
+ requests.get("PING_URL", timeout=10)
+except requests.RequestException as e:
+ # Log ping failure here...
+ print("Ping failed: %s" % e)
```
Otherwise, you can use the urllib standard module.
diff --git a/templates/front/snippets/bash_curl.html b/templates/front/snippets/bash_curl.html
index 1df710c1..0e994ae8 100644
--- a/templates/front/snippets/bash_curl.html
+++ b/templates/front/snippets/bash_curl.html
@@ -1,4 +1,3 @@
-# using curl:
-# (make sure it is installed on your system!)
-curl --retry 3 {{ ping_url }}
+# using curl (10 second timeout, retry up to 5 times):
+curl -m 10 --retry 5 {{ ping_url }}
diff --git a/templates/front/snippets/bash_curl.txt b/templates/front/snippets/bash_curl.txt
index 2279949f..3fbc33eb 100644
--- a/templates/front/snippets/bash_curl.txt
+++ b/templates/front/snippets/bash_curl.txt
@@ -1,3 +1,2 @@
-# using curl:
-# (make sure it is installed on your system!)
-curl --retry 3 PING_URL
+# using curl (10 second timeout, retry up to 5 times):
+curl -m 10 --retry 5 PING_URL
diff --git a/templates/front/snippets/bash_wget.html b/templates/front/snippets/bash_wget.html
index 060a5c65..bee30734 100644
--- a/templates/front/snippets/bash_wget.html
+++ b/templates/front/snippets/bash_wget.html
@@ -1,3 +1,3 @@
-# using wget:
-wget {{ ping_url }} -O /dev/null
+# using wget (10 second timeout, retry up to 5 times):
+wget {{ ping_url }} -T 10 -t 5 -O /dev/null
diff --git a/templates/front/snippets/bash_wget.txt b/templates/front/snippets/bash_wget.txt
index e309edb3..ea78fcfb 100644
--- a/templates/front/snippets/bash_wget.txt
+++ b/templates/front/snippets/bash_wget.txt
@@ -1,2 +1,2 @@
-# using wget:
-wget PING_URL -O /dev/null
+# using wget (10 second timeout, retry up to 5 times):
+wget PING_URL -T 10 -t 5 -O /dev/null
diff --git a/templates/front/snippets/browser.html b/templates/front/snippets/browser.html
index 131fc734..2f867e9b 100644
--- a/templates/front/snippets/browser.html
+++ b/templates/front/snippets/browser.html
@@ -1,4 +1,4 @@
-// the server returns appropriate CORS headers so cross-domain AJAX requests should work:
+// the server returns appropriate CORS headers so cross-domain AJAX requests work:
var xhr = new XMLHttpRequest();
xhr.open('GET', '{{ ping_url }}', true);
xhr.send(null);
diff --git a/templates/front/snippets/browser.txt b/templates/front/snippets/browser.txt
index 1805a685..be4f7062 100644
--- a/templates/front/snippets/browser.txt
+++ b/templates/front/snippets/browser.txt
@@ -1,4 +1,4 @@
-// the server returns appropriate CORS headers so cross-domain AJAX requests should work:
+// the server returns appropriate CORS headers so cross-domain AJAX requests work:
var xhr = new XMLHttpRequest();
xhr.open('GET', 'PING_URL', true);
xhr.send(null);
\ No newline at end of file
diff --git a/templates/front/snippets/crontab.html b/templates/front/snippets/crontab.html
index 8937fb9b..2c2e6793 100644
--- a/templates/front/snippets/crontab.html
+++ b/templates/front/snippets/crontab.html
@@ -1,3 +1,3 @@
# m h dom mon dow command
- 8 6 * * * /home/user/backup.sh && curl -fsS --retry 3 -o /dev/null {{ ping_url }}
+ 8 6 * * * /home/user/backup.sh && curl -fsS -m 10 --retry 5 -o /dev/null {{ ping_url }}
diff --git a/templates/front/snippets/crontab.txt b/templates/front/snippets/crontab.txt
index 1db344f6..f1163e36 100644
--- a/templates/front/snippets/crontab.txt
+++ b/templates/front/snippets/crontab.txt
@@ -1,2 +1,2 @@
# m h dom mon dow command
- 8 6 * * * /home/user/backup.sh && curl -fsS --retry 3 -o /dev/null PING_URL
+ 8 6 * * * /home/user/backup.sh && curl -fsS -m 10 --retry 5 -o /dev/null PING_URL
diff --git a/templates/front/snippets/python_requests.html b/templates/front/snippets/python_requests.html
index a97a4ff2..70a90711 100644
--- a/templates/front/snippets/python_requests.html
+++ b/templates/front/snippets/python_requests.html
@@ -1,4 +1,9 @@
# using requests:
import requests
-requests.get("{{ ping_url }}")
+
+try:
+ requests.get("{{ ping_url }}", timeout=10)
+except requests.RequestException as e:
+ # Log ping failure here...
+ print("Ping failed: %s" % e)
diff --git a/templates/front/snippets/python_requests.txt b/templates/front/snippets/python_requests.txt
index 72a8fb89..31073f28 100644
--- a/templates/front/snippets/python_requests.txt
+++ b/templates/front/snippets/python_requests.txt
@@ -1,3 +1,8 @@
# using requests:
import requests
-requests.get("PING_URL")
+
+try:
+ requests.get("PING_URL", timeout=10)
+except requests.RequestException as e:
+ # Log ping failure here...
+ print("Ping failed: %s" % e)
\ No newline at end of file
diff --git a/templates/front/welcome.html b/templates/front/welcome.html
index 4ebdb35c..c8aa847b 100644
--- a/templates/front/welcome.html
+++ b/templates/front/welcome.html
@@ -37,7 +37,7 @@
For each of your periodic tasks,
- {% site_name %} provides an unique URL like this one:
+ {% site_name %} provides an unique URL similar to this one:
{{ ping_url }}
@@ -118,10 +118,15 @@
- As an alternative to HTTP and HTTPS requests,
- you can "ping" this check by sending an
- email message to
- {{ check.email }}
+ As an alternative to HTTP requests,
+ you can also report "liveness" by
+ sending email messages.
+
+
+ You can instruct {% site_name %} to look for a particular
+ keyword in the subject line. This is handy when your backup
+ software sends an email after every run, and uses a different
+ subject line depending on success or failure.