All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generator.server.springboot.custom-jhlite.tests-ci.start.sh.mustache Maven / Gradle / Ivy

There is a newer version: 1.18.1
Show newest version
#!/usr/bin/env bash

PORT=$1
if [[ $PORT == '' ]]; then
  echo "*** Using default port {{serverPort}}"
  PORT='{{serverPort}}'
fi

echo "*** Waiting 5sec to be sure the Jar is here"
sleep 5

echo "*** List folder"
ls -al

if test -f "mvnw"; then
  JAR_DIRECTORY="target"
elif test -f "gradlew"; then
  JAR_DIRECTORY="build/libs/"
fi

echo "*** Identifying application executable..."
export EXEC_JAR=$(\
  find ${JAR_DIRECTORY} -maxdepth 1 -name "*-exec.jar" | grep . \
  || find ${JAR_DIRECTORY} -maxdepth 1 -name "*.jar" | grep -v "\-javadoc" | grep -v "\-sources" | grep -v "\-tests" | grep -v "\-plain" \
)

echo "*** Starting application using ${EXEC_JAR}..."
java \
  -jar ${EXEC_JAR} \
  --logging.level.ROOT=OFF & > /dev/null
echo $! > .pid-jhlite

retryCount=1
maxRetry=30
httpUrl="http://localhost:"$PORT"/management/health"

rep=$(curl -v "$httpUrl")
status=$?
while [ "$status" -ne 0 ] && [ "$retryCount" -le "$maxRetry" ]; do
  echo "*** [$(date)] Application not reachable yet. Sleep and retry - retryCount =" $retryCount "/" $maxRetry
  retryCount=$((retryCount+1))
  sleep 5
  rep=$(curl -v "$httpUrl")
  status=$?
done

if [ "$status" -ne 0 ]; then
  echo "*** [$(date)] Not connected after" $retryCount " retries."
  exit 1
fi




© 2015 - 2024 Weber Informatics LLC | Privacy Policy