diff --git a/python_apps/pypo/airtime-liquidsoap b/python_apps/pypo/airtime-liquidsoap index 259ff4646..0812bd47d 100755 --- a/python_apps/pypo/airtime-liquidsoap +++ b/python_apps/pypo/airtime-liquidsoap @@ -10,7 +10,11 @@ ls_param="/usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq" export PYTHONPATH=${api_client_path} -cd /usr/lib/airtime/pypo/bin/liquidsoap_scripts +SCRIPT=`readlink -f $0` +# Absolute directory this script is in +SCRIPTPATH=`dirname $SCRIPT` + +cd $SCRIPTPATH/liquidsoap_scripts python generate_liquidsoap_cfg.py exec ${ls_path} ${ls_param} 2>&1 diff --git a/python_apps/pypo/liquidsoap_scripts/generate_liquidsoap_cfg.py b/python_apps/pypo/liquidsoap_scripts/generate_liquidsoap_cfg.py index b123763e2..6144058e0 100644 --- a/python_apps/pypo/liquidsoap_scripts/generate_liquidsoap_cfg.py +++ b/python_apps/pypo/liquidsoap_scripts/generate_liquidsoap_cfg.py @@ -1,5 +1,6 @@ import logging import sys +import time from api_clients.api_client import AirtimeApiClient def generate_liquidsoap_config(ss): @@ -26,10 +27,19 @@ def generate_liquidsoap_config(ss): logging.basicConfig(format='%(message)s') ac = AirtimeApiClient(logging.getLogger()) -try: - ss = ac.get_stream_setting() - generate_liquidsoap_config(ss) -except Exception, e: - logging.error(str(e)) - print "Unable to connect to the Airtime server." - sys.exit(1) +attempts = 0 +max_attempts = 5 + +while True: + try: + ss = ac.get_stream_setting() + generate_liquidsoap_config(ss) + break + except Exception, e: + if attempts == max_attempts: + print "Unable to connect to the Airtime server." + logging.error(str(e)) + sys.exit(1) + else: + time.sleep(3) + attempts += 1