Update docker build process

This commit is contained in:
anthorob committed 2022-06-23 11:57:26 -04:00
1 parent 1d26918fb3
commit 6544e982c6
5 files changed
+132 -7

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
function prop {
grep "${1}" bot.properties | cut -d'=' -f2
}
function _term() {
echo "Caught SIGTERM/SIGINT signal, graceful shutdown of bot.."
if [ -z "$pid" ]; then
echo "Bot isn't running, exiting."
exit 0
else
/usr/bin/curl --no-progress-meter http://localhost:"$API_PORT"/actions/shutdown
echo "Waiting 2 seconds for bot shutdown"
sleep 2
fi
}
trap _term SIGTERM
trap _term SIGINT
if [ ! -f /bin/nc ]; then
echo "nc not found. Exiting."
exit 1
fi
if [ -z "$API_PORT" ]; then
API_PORT=9000;
fi
if [ -z "$MYSQL_HOST" ]; then
MYSQL_HOST="$(prop 'MYSQL_HOST')"
fi
if [ -z "$MYSQL_PORT" ]; then
MYSQL_PORT=$(prop 'MYSQL_PORT')
fi
echo "Waiting 10 seconds for database to start.."
sleep 10
echo "Checking if MySQL / MariaDB is started.."
if /bin/nc -z "$MYSQL_HOST" "$MYSQL_PORT"; then
echo "Database OK. Starting bot..";
/usr/local/openjdk-17/bin/java -jar target/netneutrality-jar-with-dependencies.jar &
pid=$!
wait "$pid"
else
echo "No connection to database, shutting down.."
exit 1
fi