From 1b82207934de42725dd697df1c752884a91896fe Mon Sep 17 00:00:00 2001 From: Gerhard Salvini Date: Tue, 26 Mar 2024 17:00:42 +0100 Subject: [PATCH] Migrated TransFAIR start logic from launch file to docker-compose The start-up logic for TransFAIR is specific to the ECDC/EHDS2 Bridgehead, and did not belong in the TransFAIR repo. This commit fixes that. It also honours the change of the TransFAIR branch name for this project, "ehds2". --- README.md | 6 +++++ bbmri/modules/ehds2-compose.yml | 42 ++++++++++++++++++--------------- lib/functions.sh | 2 +- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index a6bf032..eb1d8ef 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,12 @@ To get the right Beam certificate for your setup, you will need to edit the foll - bbmri/modules/ehds2.root.crt.pem - bbmri/modules/ehds2.test.root.crt.pem +You will also need to edit: + +./bbmri/modules/ehds2-setup.sh + +and set the broker address correctly for your site. + When you first start the Bridgehead, it will clone two extra repositories into /srv/docker, namely, focus and transfair. It will automatically build local images of these repositories for you. These components have the following functionality that has been customized for ECDC: - *focus.* This component is responsible for completing the CQL that is used for running queries against the Blaze FHIR store. It uses a set of templates for doing this. Extra templates have been written for the ECDC use case. diff --git a/bbmri/modules/ehds2-compose.yml b/bbmri/modules/ehds2-compose.yml index 5296a90..5c202c2 100644 --- a/bbmri/modules/ehds2-compose.yml +++ b/bbmri/modules/ehds2-compose.yml @@ -46,26 +46,30 @@ services: #WRITE_BUNDLES_TO_FILE: "true" AMR_FILE_PATH: "/app/data" restart: on-failure - #command: sh -c "sleep 60 && rm -rf /app/test/* && ([ ! -f "/app/lock" && ] && java -jar transFAIR.jar && touch "/app/lock) && tail -f /dev/null" - #command: sh -c "sleep 60 && rm -rf /app/test/* && java -jar transFAIR.jar && tail -f /dev/null" - #command: sh -c "echo listing /app/data && ls -la /app/data && /app/launch.sh" - #command: sh -c "echo listing /app/data && ls -la /app/data && [ "$(ls -A /app/data)" ] && [ ! -f "/app/data/lock" ] && /app/launch.sh & tail -f /dev/null" - #command: sh -c "echo listing /app/data && ls -la /app/data && [ ! -z "$(ls -A /app/data)" ] && [ ! -f "/app/data/lock" ] && /app/launch.sh & tail -f /dev/null" - #command: bash -c "echo listing /app/data && ls -la /app/data && [ ! -z "$(ls -A /app/data)" ] && [ ! -f "/app/data/lock" ] && /app/launch.sh & tail -f /dev/null" - #command: bash -c "echo listing /app/data && ls -la /app/data && [ ! -f "/app/data/lock" ] && /app/launch.sh & tail -f /dev/null" - #command: bash -c "echo listing /app/data && ls -la /app/data && [ ! -z "$(find /app/data -mindepth 1 -maxdepth 1)" ] && [ ! -f "/app/data/lock" ] && /app/launch.sh & tail -f /dev/null" - #command: bash -c "echo listing /app/data && ls -la /app/data && [ ! -z $(ls -A /app/data) ] && [ ! -f /app/data/lock ] && /app/launch.sh & tail -f /dev/null" - #command: bash -c "echo listing /app/data && ls -la /app/data && [ ! -f /app/data/lock ] && /app/launch.sh & tail -f /dev/null" # works! - #command: bash -c "echo listing /app/data && ls -la /app/data && [ ! -z `ls -A /app/data` ] && [ ! -f /app/data/lock ] && /app/launch.sh & tail -f /dev/null" - #command: bash -c "echo listing /app/data && ls -la /app/data && [ -f /app/data/*.csv ] && [ ! -f /app/data/lock ] && /app/launch.sh & tail -f /dev/null" # works! - command: bash -c "echo listing /app/data && ls -la /app/data && [ -f /app/data/*.[cC][sS][vV] ] && [ ! -f /app/data/lock ] && /app/launch.sh & tail -f /dev/null" - #command: sh -c "echo listing /app/data && ls -la /app/data && [ ! -z $(ls -A /app/data) ] && [ ! -f /app/data/lock ] && /app/launch.sh & tail -f /dev/null" - #command: sh -c "rm -rf /app/test/* && java -jar transFAIR.jar" + # The start up logic for TransFAIR is kind of complicated for the ECDC/EHDS2 + # pilot. This is because we only want to run it if 1. there are source data + # files to be transformed and 2. if there is no lock file. We also need to + # wait for Blaze to start, TransFAIR does not check for this. And finally, + # once TransFAIR has finished loading data, a lock file is created, to stop + # a time-consuming repeat run. + command: bash -c " \ + echo listing /app/data && \ + ls -la /app/data && \ + [ -f /app/data/*.[cC][sS][vV] ] && \ + [ ! -f /app/data/lock ] && \ + ( \ + echo 'Wait for Blaze to finish initializing' ; \ + sleep 60 ; \ + echo 'Remove old output files' ; \ + rm -rf /app/test/* ; \ + cd /app ; \ + echo 'Run TransFAIR' ; \ + java -jar transFAIR.jar ; \ + echo 'Touching lock file' ; \ + touch /app/data/lock \ + ) & tail -f /dev/null" + # If you put .csv files into ./../ecdc/data, TransFAIR will try to process them. volumes: - #- /home/gerhard/Projects/EHDS2/PrototypeSpring2024/test/:/app/test/ - #- /home/gerhard/Projects/EHDS2/PrototypeSpring2024/Data/:/app/data/ - #- ../ecdc/test:/app/test/ - #- ../ecdc/data:/app/data/ - ../../ecdc/test:/app/test/ - ../../ecdc/data:/app/data/ diff --git a/lib/functions.sh b/lib/functions.sh index b32aabe..03b6868 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -267,7 +267,7 @@ function clone_repo_if_nonexistent() { function clone_transfair_if_nonexistent() { local base_dir="$1" - clone_repo_if_nonexistent https://github.com/samply/transFAIR.git $base_dir/transfair main_ecdc_amt_prototype + clone_repo_if_nonexistent https://github.com/samply/transFAIR.git $base_dir/transfair ehds2 } function clone_focus_if_nonexistent() {