-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
57 lines (45 loc) · 1.71 KB
/
entrypoint.sh
File metadata and controls
57 lines (45 loc) · 1.71 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
set -e
echo " ____ __ __ ___ __ "
echo " / __ \\____ _____/ /_____ _/ /_ ____ _________ / | ____ ____ ____ / /_ "
echo " / /_/ / __ \\/ ___/ __/ __ / __ \\/ __ / ___/ _ \\ / /| |/ __ / _ \\/ __ \\/ __/ "
echo " / ____/ /_/ / / / /_/ /_/ / /_/ / /_/ (__ ) __/ / ___ / /_/ / __/ / / / /_ "
echo " /_/ \\____/_/ \\__/\\__,_/_.___/\\__,_/____/\\___/ /_/ |_|\\__, /\\___/_/ /_/\\__/ "
echo " /____/ "
if [ "$APP_ENV" = "production" ]; then
if [ -f /app/version.env ]; then
. /app/version.env
PROJECT_NAME_VERSION=${APP_VERSION:-production}
else
PROJECT_NAME_VERSION="development"
fi
else
PKG_ID=$(cargo pkgid 2>/dev/null || echo "unknown#0.0.0")
PROJECT_NAME_VERSION=${PKG_ID##*#}
fi
echo "[INFO] Project: ${PROJECT_NAME_VERSION}"
if [ -n "$TZ" ]; then
if [ -f "/usr/share/zoneinfo/$TZ" ]; then
ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
echo "$TZ" > /etc/timezone
echo "[INFO] Timezone set to $TZ"
else
echo "[WARN] Timezone '$TZ' not found. Using default."
fi
fi
echo "[entrypoint] APP_ENV=$APP_ENV"
echo "[entrypoint] Starting Redis..."
redis-server --daemonize yes
echo "[entrypoint] Waiting for Redis to be ready..."
until redis-cli ping >/dev/null 2>&1; do
echo "[entrypoint] Redis not ready, sleeping 1s..."
sleep 1
done
echo "[entrypoint] Redis is ready"
if [ "$APP_ENV" = "production" ]; then
echo "[entrypoint] Production mode"
exec /usr/local/bin/app
else
echo "[entrypoint] Development mode (live reload)"
exec cargo watch -x run
fi