Internal
Public Access
Update entrypoint.sh to support PostgreSQL
- Auto-detect database type from DATABASE_URL - Use pg_isready for PostgreSQL health check - Use mysqladmin ping for MariaDB/MySQL - Default to postgres if not specified 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.5
parent
26fda44d7a
commit
2afeec85da
+20
-7
@@ -12,24 +12,37 @@ echo -e "${GREEN}KeepItGoing Docker Entrypoint${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
|
||||
# Extract database host from DATABASE_URL or use DB_HOST env var
|
||||
DB_HOST=${DB_HOST:-mariadb}
|
||||
DB_HOST=${DB_HOST:-postgres}
|
||||
|
||||
# Wait for MariaDB to be ready
|
||||
echo -e "${YELLOW}Waiting for MariaDB at ${DB_HOST}...${NC}"
|
||||
# Detect database type from DATABASE_URL
|
||||
if echo "$DATABASE_URL" | grep -q "mysql\|mariadb"; then
|
||||
DB_TYPE="mysql"
|
||||
DB_CHECK_CMD="mysqladmin ping -h${DB_HOST} --silent"
|
||||
elif echo "$DATABASE_URL" | grep -q "postgres"; then
|
||||
DB_TYPE="postgres"
|
||||
DB_CHECK_CMD="pg_isready -h ${DB_HOST} -U ${DB_USER:-keepitgoing}"
|
||||
else
|
||||
# Default to postgres
|
||||
DB_TYPE="postgres"
|
||||
DB_CHECK_CMD="pg_isready -h ${DB_HOST} -U ${DB_USER:-keepitgoing}"
|
||||
fi
|
||||
|
||||
# Wait for database to be ready
|
||||
echo -e "${YELLOW}Waiting for database at ${DB_HOST}...${NC}"
|
||||
max_attempts=30
|
||||
attempt=0
|
||||
|
||||
while ! mysqladmin ping -h"${DB_HOST}" --silent 2>/dev/null; do
|
||||
while ! eval $DB_CHECK_CMD 2>/dev/null; do
|
||||
attempt=$((attempt + 1))
|
||||
if [ $attempt -eq $max_attempts ]; then
|
||||
echo -e "${RED}ERROR: MariaDB did not become available in time${NC}"
|
||||
echo -e "${RED}ERROR: Database did not become available in time${NC}"
|
||||
exit 1
|
||||
fi
|
||||
echo "Waiting for MariaDB... ($attempt/$max_attempts)"
|
||||
echo "Waiting for database... ($attempt/$max_attempts)"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo -e "${GREEN}✓ MariaDB is ready!${NC}"
|
||||
echo -e "${GREEN}✓ Database is ready!${NC}"
|
||||
|
||||
# Function to run migrations
|
||||
run_migrations() {
|
||||
|
||||
Reference in New Issue
Block a user