Skip to content

Commit

Permalink
Added assertion to quickly fail if something goes wrong.
Browse files Browse the repository at this point in the history
I would move on with the process, making the real error unclear.
  • Loading branch information
jmlord committed Mar 4, 2024
1 parent 1d1c449 commit 7a39a74
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions server-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
# Optional arg 1: branch name of server repo, default "main"
branch=${1:-"main"}
shift
# Additionnal optional args will be appended to the docker compose up command.
# Additionnal optional args will be appended to the docker compose up command.
# Typical use is to give a specific service name to (re)start only that one.
options=$@

function assertSuccess {
RED="\033[31m"
ENDCOLOR="\033[0m"
if [[ $? -ne 0 ]] ; then
echo -e "${RED}FAILED${ENDCOLOR}" ; exit 1
fi
}

echo "Updating server init script..."
if cd .server; then
# Check for a branch change
Expand All @@ -23,13 +31,18 @@ if cd .server; then
ls -a | grep -Ev "^(\.git|\.|\.\.)$" | xargs rm -r
fi

git fetch --no-tag --depth 1 origin $branch
else
git fetch --no-tag --depth 1 origin $branch
assertSuccess
else
git clone -n [email protected]:GEO-BON/bon-in-a-box-pipeline-engine.git --branch $branch --single-branch .server --depth 1
cd .server;
assertSuccess
cd .server
assertSuccess
fi

echo "Using branch $branch."
git checkout origin/$branch -- prod-server.sh
assertSuccess

./prod-server.sh checkout $branch
./prod-server.sh up $options

0 comments on commit 7a39a74

Please sign in to comment.