From 78ce182a26925bb12e16c7aac6b359130db709e7 Mon Sep 17 00:00:00 2001 From: Chris Roeder CUAnschutz Date: Tue, 24 Jan 2023 10:04:13 -0700 Subject: [PATCH] fixes, better db checks andtolerance --- README.md | 8 ++++++-- bin/install.sh | 3 ++- bin/start-hapi.sh | 15 +++++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index df6939a..5bbc2de 100644 --- a/README.md +++ b/README.md @@ -62,16 +62,20 @@ The defaults are set up to run against a postgres database on the localhost at p ## Install, start and load: - set environment variables for the database (PG* in the case of postgres) and the URL for htting the server (HAPI_R4) - - `$ source profile.sh` + - `$ source bin/profile.sh` - fetch the HAPI CLI, a `ROOT.war` of the server, the aehrc fhir-owl converter and the TimsUI content - `$ bin/install.sh` - start the server - - `$ config/start-hapi.sh` + - `$ bin/start-hapi.sh` - load the vocabularies - `$ bin/loaders.sh` - test with the Jupyter notebooks available at https://github.com/HOT-Ecosystem/TSDemoBoard - assuming defaults, the `BASE_URL` there should be set in accord with values here, `BASE_URL =\"http://localhost:8001/fhir/"` - test also with the TimsUI, installed as part of this installation, accessable at http://:8001/static/index.html + - track server's progress by following the log + - `tail -f hapi.log` + - When necessary, stop with script that will stop all hapi servers on this server. + - `$ bin/stop-hapi.sh` ### Running things manually This project is set up to run things automatically. However, it is possible to run some things manually, which may be useful for troubleshooting. diff --git a/bin/install.sh b/bin/install.sh index 77fab6a..fc38962 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -11,6 +11,7 @@ cd $TIMS_DIR/hapi # DOWNLOAD the static content from TimsUI, put in $TIMS_DIR/static-files if [[ ! -f TimsUI.tar ]] ; then wget -q https://github.com/HOT-Ecosystem/TimsUI/releases/download/Jan_Connectathon/TimsUI_Jan_Connectathon.tar 2> /dev/null + mv TimsUI_Jan_Connectathon.tar TimsUI.tar mkdir $TIMS_DIR/static-files cd $TIMS_DIR/static-files tar xvf $TIMS_DIR/hapi/TimsUI.tar @@ -63,7 +64,7 @@ fi #fi # Edit application.yaml to point to $TIMS_DIR/static-files, and copy at the same time cd $TIMS_DIR -cat $TIMS_DIR/hapi/application_pg.yaml | sed "s|XXstatic-filesXX|$TIMS_DIR/static-files/|g" >> $TIMS_DIR/hapi/application.yaml +cat $TIMS_DIR/hapi/application_pg.yaml | sed "s|XXstatic-filesXX|$TIMS_DIR/static-files/|g" > $TIMS_DIR/hapi/application.yaml cd $TIMS_DIR/hapi diff --git a/bin/start-hapi.sh b/bin/start-hapi.sh index 89f1022..c38aef4 100755 --- a/bin/start-hapi.sh +++ b/bin/start-hapi.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -set -euo pipefail +set -uo pipefail -env | grep PG_ +env | grep PG if (( $? )) ; then - echo "ERROR:missing PG_* environment variables used in the applicaiton.yaml" - echo "These are distinct from the PG variables postgres uses that do not have underscores." + echo "ERROR:missing PG* environment variables used in the application.yaml" exit 1 fi +psql -lqt | awk '{ print $1 }' | grep $PGDATABASE +if (( $? )) ; then + echo "INFO: databse \"$PGDATABASE\" does not exist, creating." + createdb $PGDATABASE +else + echo "INFO: found databse \"$PGDATABASE\"." +fi + # RUN exec java -Xmx10G -jar "${TIMS_DIR}/hapi/ROOT.war" --spring.config.location="${TIMS_DIR}/hapi/" >> ${TIMS_DIR}/hapi.log &