CC-5708: proftpd hook for new File API

added handling for if the web server is down
This commit is contained in:
drigato 2014-03-27 15:46:42 -04:00
parent eb72f25151
commit 2bc37b9fea

View file

@ -1,5 +1,10 @@
#! /bin/bash
post_file() {
#kill process after 30 minutes (360*5=30 minutes)
max_retry=360
retry_count=0
file_path=$1
filename="${file_path##*/}"
@ -23,4 +28,14 @@ instance_conf_path=$base_instance_path$instance_path$airtime_conf_path
api_key=$(sudo awk -F "=" '/api_key/ {print $2}' $instance_conf_path)
curl $url -u $api_key":" -X POST -F "file=@$file_path" -F "name=$filename"
until curl --max-time 30 $url -u $api_key":" -X POST -F "file=@$file_path" -F "name=$filename"
do
retry_count=$[$retry_count+1]
if [ $retry_count -ge $max_retry ]; then
break
fi
sleep 5
done
}
post_file "$1" &