Skip to content
Snippets Groups Projects
Commit 27707892 authored by Pierre-Gilles Levallois's avatar Pierre-Gilles Levallois
Browse files

First try : launch init scripts

parent cd38ebc4
Branches
Tags v1.3.0
1 merge request!3Launch script
Pipeline #44321 passed
...@@ -92,7 +92,7 @@ Build Calqul Python: ...@@ -92,7 +92,7 @@ Build Calqul Python:
- *set_env - *set_env
- *build_and_push_image - *build_and_push_image
rules: rules:
- if: '$CI_COMMIT_BRANCH == "develop"' - if: '$CI_COMMIT_BRANCH == "launch-script"'
changes: # build image only if sources have changed. changes: # build image only if sources have changed.
- Dockerfiles/python/Dockerfile # Image definition has changed - Dockerfiles/python/Dockerfile # Image definition has changed
- Dockerfiles/python/scripts/* # Python scripts have changed - Dockerfiles/python/scripts/* # Python scripts have changed
...@@ -115,7 +115,7 @@ Build Calqul Postgis: ...@@ -115,7 +115,7 @@ Build Calqul Postgis:
- cd $IMAGE_DIR - cd $IMAGE_DIR
- *build_and_push_image - *build_and_push_image
rules: rules:
- if: '$CI_COMMIT_BRANCH == "develop"' - if: '$CI_COMMIT_BRANCH == "launch-script"'
changes: # build image only if sources have changed. changes: # build image only if sources have changed.
- Dockerfiles/db/**/* # db scripts have changed - Dockerfiles/db/**/* # db scripts have changed
- .gitlab-ci.yml - .gitlab-ci.yml
...@@ -136,7 +136,7 @@ Deploy Calqul: ...@@ -136,7 +136,7 @@ Deploy Calqul:
script: script:
- *apply_confs - *apply_confs
rules: rules:
- if: '$CI_COMMIT_BRANCH == "develop"' - if: '$CI_COMMIT_BRANCH == "launch-script"'
tags: tags:
#- ns-arb-d01 @TODO : Change after when the right namespace is available #- ns-arb-d01 @TODO : Change after when the right namespace is available
- ns-test-d01 # No possibility to put varaibles here :( - ns-test-d01 # No possibility to put varaibles here :(
\ No newline at end of file
#!/bin/bash #!/bin/bash
################################################################################
# ARB : Lancement du recalcul des indices du calque de plantabilité. # ARB : Lancement du recalcul des indices du calque de plantabilité.
# ################################################################################
# screen -dmS calque_metro python3 main.py computeAll 5 DATA_REPO="https://forge.grandlyon.com/erasme/data-recalcul-calque.git"
python3 main.py initCommunes scripts_dir="/app"
data_dir="/arb-data/source-files/data-recalcul-calque"
stage=1
line="\e[39m-----------------------------------------------"
need_update=1
sleep 300 ################################################################################
# functions
################################################################################
# python3 main.py initGrid #---------------------------------------------------------------
# python3 main.py initDatas # Functions
#---------------------------------------------------------------
# Logging
stage () {
echo -e $line
echo -e "\e[96m$stage. $1\e[39m"
echo -e $line
stage=$((stage+1))
}
# Formatting log line
comment () {
echo -e "\e[39m\t-> $1\e[39m"
}
# Check the last command return code (must be insterted just after the commend )
check () {
if [ $? -eq 0 ]; then
comment "\e[32mOk.\e[39m"
else
comment "\e[31mERROR !...\e[39m"
exit 1
fi;
}
################################################################################
mkdir -p $data_dir
stage "Check source files in $data_dir"
cd $data_dir
current_commit=$(git rev-parse --short HEAD)
if [ $? -eq 128 ]; then
comment "Data repository is empty. Is this your first time, young Padawan ?"
comment "Cloning repo, it can take a while..."
cd ..
git clone $DATA_REPO
need_update=0
else
comment "Current commit is $current_commit"
cd $data_dir
fi;
# Checking for update...
[ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | sed 's/\// /g') | cut -f1) ] && need_update=0 || need_update=1
if [ $need_update -eq 0 ]; then
# We are up to date
comment "\e[32mData are up to date."
else
comment "\e[93mNew version of source data is available !\e[39m"
git pull origin main
new_commit=$(git rev-parse --short HEAD)
comment "New commit is : \e[93m'$new_commit'\e[39m"
git diff --compact-summary $current_commit $new_commit
fi;
stage "Launch computations..."
cd $scripts_dir
comment "Init communes"
python main.py initCommunes
python3 main.py initGrid
python3 main.py initDatas
# Multiprocessing task # Multiprocessing task
# python3 main.py computeFactors # python3 main.py computeFactors
...@@ -16,4 +86,7 @@ sleep 300 ...@@ -16,4 +86,7 @@ sleep 300
# python3 main.py computeIndices # python3 main.py computeIndices
# Launching everything, it is possible to give a list of township # Launching everything, it is possible to give a list of township
# python3 main.py computeAll # python3 main.py computeAll
\ No newline at end of file
stage "Sleeping a while for debug purpose..."
sleep 300
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment