1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-25 15:59:38 +02:00
AdventureLog/startup.sh

52 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/sh
# Function to check if the database is ready
wait_for_db() {
echo "Waiting for the database to start up..."
while ! nc -z db 5432; do
sleep 1
done
echo "Database is now available."
}
# Function to run SQL scripts
run_sql_scripts() {
echo "Running SQL scripts..."
# Define the path to your SQL scripts
SQL_SCRIPTS_PATH="/sql" # Replace with the path to your SQL scripts
# Run each SQL script in the directory using the DATABASE_URL
for sql_script in "$SQL_SCRIPTS_PATH"/*.sql; do
echo "Running script: $sql_script"
psql "$DATABASE_URL" -f "$sql_script"
done
echo "Finished running SQL scripts."
}
# Start your application here
# Print message
echo "Starting AdventureLog"
# Wait for the database to start up
if [ -z "$SKIP_DB_WAIT" ] || [ "$SKIP_DB_WAIT" = "false" ]; then
wait_for_db
fi
# Wait for the database to start up
2024-04-10 01:31:10 +00:00
# generate the schema
2024-04-12 14:26:30 +00:00
# npm run generate
2024-04-10 01:31:10 +00:00
# Run database migration
npm run migrate
# Run SQL scripts
2024-04-26 22:43:13 +00:00
# run_sql_scripts
echo "The origin to be set is: $ORIGIN"
# Start the application
ORIGIN=$ORIGIN node build