From ecb72862d7e76705f4141e1ef7e39f1058f28c78 Mon Sep 17 00:00:00 2001 From: bradsawadye Date: Tue, 5 Sep 2023 15:57:20 +0200 Subject: [PATCH] Wait for mongo to be up and running before replication can be done --- .../docker-compose.await-helper-mongo.yml | 10 ++++++++++ interoperability-layer-openhim/swarm.sh | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 interoperability-layer-openhim/docker-compose.await-helper-mongo.yml diff --git a/interoperability-layer-openhim/docker-compose.await-helper-mongo.yml b/interoperability-layer-openhim/docker-compose.await-helper-mongo.yml new file mode 100644 index 00000000..c02d4ffe --- /dev/null +++ b/interoperability-layer-openhim/docker-compose.await-helper-mongo.yml @@ -0,0 +1,10 @@ +version: '3.9' + +services: + await-helper: + image: jembi/await-helper:1.0.1 + deploy: + replicas: 1 + restart_policy: + condition: none + command: '-k http://mongo-1:27017' diff --git a/interoperability-layer-openhim/swarm.sh b/interoperability-layer-openhim/swarm.sh index 469fa89b..f96dd679 100644 --- a/interoperability-layer-openhim/swarm.sh +++ b/interoperability-layer-openhim/swarm.sh @@ -55,6 +55,8 @@ function initialize_package() { if [[ "${CLUSTERED_MODE}" == "true" ]]; then try "${COMPOSE_FILE_PATH}/initiate-replica-set.sh $STACK" throw "Fatal: Initiate Mongo replica set failed" else + config::await_service_running "mongo-1" "${COMPOSE_FILE_PATH}"/docker-compose.await-helper-mongo.yml "1" "$STACK" + try "docker exec -i $(docker ps -q -f name=openhim_mongo) mongo --eval \"rs.initiate()\"" throw "Could not initiate replica set for the single mongo instance. Some services use \ mongo event listeners which only work with a replica set" fi