BPEL Bot commited on
Commit
44962ca
·
1 Parent(s): 225ea4e

Log DB scheme and strip psql wrapper

Browse files
Files changed (1) hide show
  1. docker-entrypoint.sh +14 -1
docker-entrypoint.sh CHANGED
@@ -5,7 +5,17 @@ log() {
5
  echo "[entrypoint] $*"
6
  }
7
 
8
- DB_URL="${OTREE_DATABASE_URL:-${DATABASE_URL:-sqlite:////tmp/otree.sqlite3}}"
 
 
 
 
 
 
 
 
 
 
9
  DB_PATH=""
10
 
11
  if [[ "$DB_URL" == sqlite:////* ]]; then
@@ -23,6 +33,9 @@ if [[ -n "$DB_PATH" ]]; then
23
  fi
24
  fi
25
 
 
 
 
26
  PORT="${PORT:-8000}"
27
  log "Starting oTree prodserver on 0.0.0.0:${PORT}"
28
  exec otree prodserver1of2 0.0.0.0:${PORT}
 
5
  echo "[entrypoint] $*"
6
  }
7
 
8
+ RAW_DB_URL="${OTREE_DATABASE_URL:-${DATABASE_URL:-sqlite:////tmp/otree.sqlite3}}"
9
+
10
+ # Accept accidental "psql 'url'" copy-pastes by extracting the quoted URL.
11
+ if [[ "$RAW_DB_URL" == psql* ]]; then
12
+ CLEANED=$(printf '%s' "$RAW_DB_URL" | sed -n "s/.*'\(postgres[^']*\)'.*/\1/p")
13
+ if [[ -n "$CLEANED" ]]; then
14
+ RAW_DB_URL="$CLEANED"
15
+ fi
16
+ fi
17
+
18
+ DB_URL="$RAW_DB_URL"
19
  DB_PATH=""
20
 
21
  if [[ "$DB_URL" == sqlite:////* ]]; then
 
33
  fi
34
  fi
35
 
36
+ SCHEME=$(printf '%s' "$DB_URL" | cut -d: -f1)
37
+ log "Database scheme detected: ${SCHEME:-unknown}"
38
+
39
  PORT="${PORT:-8000}"
40
  log "Starting oTree prodserver on 0.0.0.0:${PORT}"
41
  exec otree prodserver1of2 0.0.0.0:${PORT}