-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathentrypoint.sh
More file actions
38 lines (32 loc) · 1.21 KB
/
Copy pathentrypoint.sh
File metadata and controls
38 lines (32 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
set -e
# BEAM distribution: set node name and cookie if provided
[ -n "$NODE_NAME" ] && export RELEASE_NODE="$NODE_NAME"
[ -n "$CLUSTER_COOKIE" ] && export RELEASE_COOKIE="$CLUSTER_COOKIE"
# Long-name distribution: names containing a dot need -name mode + EPMD
if echo "$NODE_NAME" | grep -q '\.'; then
export RELEASE_DISTRIBUTION=name
echo "Starting EPMD for long-name distribution..."
epmd -daemon
fi
# Wait for PostgreSQL to be ready (handles restart timing)
DB_HOST="${DATABASE_HOSTNAME:-db}"
DB_USER="${DATABASE_USERNAME:-alexclaw}"
echo "Waiting for database at ${DB_HOST}..."
for i in $(seq 1 30); do
if pg_isready -h "$DB_HOST" -U "$DB_USER" -q 2>/dev/null; then
echo "Database is ready."
break
fi
if [ "$i" = "30" ]; then
echo "Database not ready after 30 attempts, proceeding anyway..."
fi
sleep 1
done
# Migrations are not run here. They run in the one-shot `migrate` service, as
# the database owner, before this container starts; this container connects as
# the application role, which may not run DDL — see AlexClaw.Database.Roles.
echo "Checking for first-boot seeding..."
bin/alex_claw eval "AlexClaw.Release.seed_examples()"
echo "Starting AlexClaw..."
exec bin/alex_claw start