Skip to content

Commit

Permalink
added port as environmental variable (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: Brian "bits" Olsen <[email protected]>
  • Loading branch information
LorenzF and bitsondatadev authored Mar 15, 2024
1 parent 29f4852 commit aa02788
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ purposes. DO NOT use for production.

ENV variables:
- METASTORE_DB_HOSTNAME - hostname used to ping metastore db during init
- METASTORE_DB_PORT - port used to ping metastore db
- METASTORE_TYPE - type of metastore db (options: mysql, postgres) (default: mysql)

16 changes: 8 additions & 8 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ MYSQL='mysql'
POSTGRES='postgres'

if [ "${METASTORE_TYPE}" = "${MYSQL}" ]; then
echo "Waiting for database on ${METASTORE_DB_HOSTNAME} to launch on 3306 ..."
while ! nc -z ${METASTORE_DB_HOSTNAME} 3306; do
echo "Waiting for database on ${METASTORE_DB_HOSTNAME} to launch on ${METASTORE_DB_PORT} ..."
while ! nc -z ${METASTORE_DB_HOSTNAME} ${METASTORE_DB_PORT}; do
sleep 1
done

echo "Database on ${METASTORE_DB_HOSTNAME}:3306 started"
echo "Init apache hive metastore on ${METASTORE_DB_HOSTNAME}:3306"
echo "Database on ${METASTORE_DB_HOSTNAME}:${METASTORE_DB_PORT} started"
echo "Init apache hive metastore on ${METASTORE_DB_HOSTNAME}:${METASTORE_DB_PORT}"

/opt/apache-hive-metastore-3.0.0-bin/bin/schematool -initSchema -dbType mysql
/opt/apache-hive-metastore-3.0.0-bin/bin/start-metastore
fi

if [ "${METASTORE_TYPE}" = "${POSTGRES}" ]; then
echo "Waiting for database on ${METASTORE_DB_HOSTNAME} to launch on 5432 ..."
while ! nc -z ${METASTORE_DB_HOSTNAME} 5432; do
echo "Waiting for database on ${METASTORE_DB_HOSTNAME} to launch on ${METASTORE_DB_PORT} ..."
while ! nc -z ${METASTORE_DB_HOSTNAME} ${METASTORE_DB_PORT}; do
sleep 1
done

echo "Database on ${METASTORE_DB_HOSTNAME}:5432 started"
echo "Init apache hive metastore on ${METASTORE_DB_HOSTNAME}:5432"
echo "Database on ${METASTORE_DB_HOSTNAME}:${METASTORE_DB_PORT} started"
echo "Init apache hive metastore on ${METASTORE_DB_HOSTNAME}:${METASTORE_DB_PORT}"

/opt/apache-hive-metastore-3.0.0-bin/bin/schematool -initSchema -dbType postgres
/opt/apache-hive-metastore-3.0.0-bin/bin/start-metastore
Expand Down

0 comments on commit aa02788

Please sign in to comment.