From 84016f79348666ef6e704eaef8274765f9388f10 Mon Sep 17 00:00:00 2001 From: Radoslav Kirilov Date: Tue, 21 Apr 2026 11:06:37 +0300 Subject: [PATCH] fix: catch and exit with error when rs initialization fails --- start-mongodb.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/start-mongodb.sh b/start-mongodb.sh index b34b56b..f8a1ccf 100755 --- a/start-mongodb.sh +++ b/start-mongodb.sh @@ -205,10 +205,21 @@ docker exec --tty $MONGODB_CONTAINER_NAME $MONGODB_CLIENT --port $MONGODB_PORT $ }) " +if [ $? -ne 0 ]; then + echo "Error initiating replica set [$MONGODB_REPLICA_SET]" + exit 2 +fi + echo "Success! Initiated replica set [$MONGODB_REPLICA_SET]" echo "::endgroup::" echo "::group::Checking replica set status [$MONGODB_REPLICA_SET]" docker exec --tty $MONGODB_CONTAINER_NAME $MONGODB_CLIENT --port $MONGODB_PORT $MONGODB_ARGS --eval "rs.status()" + +if [ $? -ne 0 ]; then + echo "Error checking replica set status [$MONGODB_REPLICA_SET]" + exit 2 +fi + echo "::endgroup::"