Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e90186432 | |||
| bbfd200ec4 | |||
| 489016782c |
+1
-1
@@ -1 +1 @@
|
||||
1.0.3
|
||||
1.0.6
|
||||
|
||||
@@ -3,27 +3,65 @@
|
||||
date_to_load=${1}
|
||||
|
||||
DockerRegistry=cloud21.cvtt.vpn:5500
|
||||
DockerImage=${DockerRegistry}/alpaca_md_day:latest
|
||||
DockerImage=${DockerRegistry}/alpaca_md_day #:latest
|
||||
LastDayFile=/home/cvtt/prod/logs/last_alpaca_hist_day
|
||||
ContainerName=alpaca_md_day
|
||||
|
||||
is_container_running() {
|
||||
local container_name=$1
|
||||
|
||||
if [ "$(docker ps --filter "name=^/${container_name}$" --filter "status=running" -q)" ]; then
|
||||
return 0 # true
|
||||
else
|
||||
return 1 # false
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if [ -z ${date_to_load} ] ; then
|
||||
echo "Yesterday data. Historical container will be killed"
|
||||
docker kill alpaca_md_day
|
||||
echo "Yesterday data has priority. Running historical container will be killed"
|
||||
docker kill ${ContainerName}
|
||||
else
|
||||
echo "Historical run ${date_to_load}"
|
||||
if is_container_running "$ContainerName"; then
|
||||
echo "Container ${ContainerName} is already running."
|
||||
exit 3
|
||||
fi
|
||||
if [ "${date_to_load}" == "next" ] ; then
|
||||
last_date=$(cat ${LastDayFile})
|
||||
if [ -z ${last_date} ] ; then
|
||||
if [ ! -e ${LastDayFile} ]; then
|
||||
echo "File ${LastDayFile} does not exist. Will try to use prev file."
|
||||
if [ ! -e ${LastDayFile}.prev ]; then
|
||||
echo "File ${LastDayFile}.prev does not exist. Aborted."
|
||||
exit 2
|
||||
fi
|
||||
mv ${LastDayFile}.prev ${LastDayFile}
|
||||
fi
|
||||
last_date=$(cat ${LastDayFile} | xargs)
|
||||
if [ -z "${last_date}" ] ; then
|
||||
echo "File ${LastDayFile} returned an empty last day. Will try to use prev file."
|
||||
if [ ! -e ${LastDayFile}.prev ]; then
|
||||
echo "File ${LastDayFile}.prev does not exist. Aborted."
|
||||
exit 2
|
||||
fi
|
||||
mv ${LastDayFile}.prev ${LastDayFile}
|
||||
last_date=$(cat ${LastDayFile} | xargs)
|
||||
if [ -z "${last_date}" ] ; then
|
||||
echo "Unable to obtain last_date. Aborted"
|
||||
exit 3
|
||||
fi
|
||||
echo "No last date_to_load in ${LastDayFile}"
|
||||
exit 1
|
||||
fi
|
||||
mv ${LastDayFile} ${LastDayFile}.prev
|
||||
date_to_load=$(date -d "${last_date} - 1 day" "+%Y-%m-%d")
|
||||
fi
|
||||
echo "Historical Data for ${date_to_load}"
|
||||
fi
|
||||
|
||||
Cmd="docker run"
|
||||
Cmd="${Cmd} --pull"
|
||||
Cmd="${Cmd} --network=host"
|
||||
Cmd="${Cmd} --name=alpaca_md_day"
|
||||
Cmd="${Cmd} --name=${ContainerName}"
|
||||
Cmd="${Cmd} --rm"
|
||||
Cmd="${Cmd} ${DockerImage}"
|
||||
Cmd="${Cmd} ${date_to_load}"
|
||||
@@ -35,7 +73,9 @@ if [ "$?" != "0" ] ; then
|
||||
exit 1 # if killed we do not save last day
|
||||
fi
|
||||
|
||||
if [ -n ${date_to_load}]; then
|
||||
# truncate to avoid false positive
|
||||
date_to_load=$(echo "${date_to_load} | xargs")
|
||||
if [ -n "${date_to_load}" ]; then
|
||||
echo "Saving date_to_load to ${LastDayFile}"
|
||||
echo ${date_to_load} > ${LastDayFile}
|
||||
fi
|
||||
Reference in New Issue
Block a user