This commit is contained in:
Oleg Sheynin 2024-07-23 14:48:59 -04:00
parent b698b847a5
commit 3357110e64
2 changed files with 30 additions and 5 deletions

View File

@ -1 +1 @@
1.0.3 1.0.4

View File

@ -3,19 +3,44 @@
date_to_load=${1} date_to_load=${1}
DockerRegistry=cloud21.cvtt.vpn:5500 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 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 if [ -z ${date_to_load} ] ; then
echo "Yesterday data. Historical container will be killed" echo "Yesterday data has priority. Running historical container will be killed"
docker kill alpaca_md_day docker kill ${ContainerName}
else 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 if [ "${date_to_load}" == "next" ] ; then
if [ ! -e ${LastDayFile} ]; then
mv ${LastDayFile}.prev ${LastDayFile}
if [ ! -e ${LastDayFile} ]; then
echo "file ${LastDayFile} does not exist"
exit 2
fi
fi
last_date=$(cat ${LastDayFile}) last_date=$(cat ${LastDayFile})
if [ -z ${last_date} ] ; then if [ -z ${last_date} ] ; then
echo "No last date_to_load in ${LastDayFile}" echo "No last date_to_load in ${LastDayFile}"
exit 1 exit 1
fi fi
mv ${LastDayFile} ${LastDayFile}.prev
date_to_load=$(date -d "${last_date} - 1 day" "+%Y-%m-%d") date_to_load=$(date -d "${last_date} - 1 day" "+%Y-%m-%d")
fi fi
echo "Historical Data for ${date_to_load}" echo "Historical Data for ${date_to_load}"
@ -23,7 +48,7 @@ fi
Cmd="docker run" Cmd="docker run"
Cmd="${Cmd} --network=host" Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=alpaca_md_day" Cmd="${Cmd} --name=${ContainerName}"
Cmd="${Cmd} --rm" Cmd="${Cmd} --rm"
Cmd="${Cmd} ${DockerImage}" Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} ${date_to_load}" Cmd="${Cmd} ${date_to_load}"