-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·20 lines (17 loc) · 786 Bytes
/
Copy pathrun.sh
File metadata and controls
executable file
·20 lines (17 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
# Container entrypoint: run DB migrations, then serve via the uvicorn CLI
# (multi-worker, uvloop). --no-access-log because AccessLogMiddleware owns the
# access log line. The final `exec` replaces this shell so uvicorn receives
# SIGTERM/SIGINT directly. set -e aborts before starting the server if a
# migration fails.
set -e
log() {
printf '{"pid":%s,"level":"INFO","message":"%s","timestamp":"%s","logger":"container"}\n' \
"$$" "$1" "$(date '+%Y-%m-%d %H:%M:%S,%3N')"
}
log "Run database migrations if any."
/app/.venv/bin/alembic upgrade head 2>&1
log "Migration complete."
log "Start server, it becomes PID=1"
exec /app/.venv/bin/uvicorn app.web.api:app --host 0.0.0.0 --port "${PORT:-8000}" \
--workers 2 --loop uvloop --no-access-log --log-config logging.conf