Commit 61670ea2 authored by Alain Takoudjou's avatar Alain Takoudjou

set default timeout of check url promise to 20 seconds

Also allow to change promise timeout by editing check_url_PROMISE_TIMEOUT file
parent e82d69be
......@@ -26,6 +26,7 @@
##############################################################################
from slapos.recipe.librecipe import GenericBaseRecipe
import sys
import os
class Recipe(GenericBaseRecipe):
"""
......@@ -33,12 +34,14 @@ class Recipe(GenericBaseRecipe):
"""
def install(self):
timeout_file = os.path.join(os.getcwd(), 'etc/check_url_PROMISE_TIMEOUT')
config = {
'url': self.options['url'],
'shell_path': self.options['dash_path'],
'curl_path': self.options['curl_path'],
'check_secure': self.options.get('check-secure', 0),
'http_code': self.options.get('http_code', '200'),
'time_out': self.options.get('timeout-file-path', timeout_file),
}
# XXX-Cedric in this script, curl won't check certificate
......
......@@ -3,13 +3,24 @@
# BEWARE: It will be overwritten automatically
URL="%(url)s"
F_TIMEOUT="%(time_out)s"
TIMEOUT=20
if [ -z "$URL" ]; then
echo "No URL specified." >&2
exit 3
fi
CODE=$(%(curl_path)s -g -k -sL $URL -w %%{http_code} --max-time 10 -o /dev/null)
if [ -s "$F_TIMEOUT" ]; then
TIMEOUT=$(cat $F_TIMEOUT)
re="^[0-9]+$"
if ! [[ $TIMEOUT =~ $re ]]; then
# Not an integer
TIMEOUT=20
fi
fi
CODE=$(%(curl_path)s -g -k -sL $URL -w %%{http_code} --max-time $TIMEOUT -o /dev/null)
if [ $? -eq 3 ]; then
echo "URL malformed: $URL." >&2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment