ohmyapi commited on
Commit
ee15c51
·
verified ·
1 Parent(s): ae8e026

fix: read-only filesystem + remove pgstore-dsn from config

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -1
  2. config.yaml +1 -1
  3. entrypoint.sh +8 -15
Dockerfile CHANGED
@@ -18,4 +18,4 @@ RUN chmod +x /app/cleanup_tokens.sh /app/entrypoint.sh
18
  ENV TZ=Asia/Shanghai
19
  EXPOSE 7860
20
 
21
- CMD ["./cli-proxy-api", "--config", "/app/config.yaml"]
 
18
  ENV TZ=Asia/Shanghai
19
  EXPOSE 7860
20
 
21
+ CMD ["/app/entrypoint.sh"]
config.yaml CHANGED
@@ -10,4 +10,4 @@ remote-management:
10
  secret-key: "${MANAGEMENT_PASSWORD}"
11
 
12
  commercial-mode: true
13
- debug: true
 
10
  secret-key: "${MANAGEMENT_PASSWORD}"
11
 
12
  commercial-mode: true
13
+ debug: false
entrypoint.sh CHANGED
@@ -4,20 +4,21 @@
4
  #
5
  # Environment variables:
6
  # CLEANUP_CRON_SCHEDULE - Cron schedule for token cleanup (default: "0 */6 * * *", every 6h)
 
 
 
 
7
  # CLEANUP_STARTUP_DELAY - Seconds to wait after service is ready before first cleanup (default: 10)
8
  #
9
 
10
- echo "[entrypoint] Starting up at $(date)" >&2
 
11
  echo "[entrypoint] Starting up at $(date)"
12
- echo "[entrypoint] User: $(id)" >&2
13
- echo "[entrypoint] Filesystem writable test: /etc=$(touch /etc/.test 2>&1 && echo 'writable' && rm -f /etc/.test || echo 'read-only')" >&2
14
- echo "[entrypoint] /tmp writable: $(touch /tmp/.test 2>&1 && echo 'yes' && rm -f /tmp/.test || echo 'no')" >&2
15
 
16
  CLEANUP_CRON_SCHEDULE="${CLEANUP_CRON_SCHEDULE:-0 */6 * * *}"
17
  CLEANUP_STARTUP_DELAY="${CLEANUP_STARTUP_DELAY:-10}"
18
 
19
  mkdir -p /tmp/logs /tmp/crontabs
20
- echo "[entrypoint] Created /tmp/logs and /tmp/crontabs" >&2
21
 
22
  # Write crontab to /tmp (HuggingFace root filesystem is read-only)
23
  cat > /tmp/crontabs/root << EOF
@@ -26,18 +27,13 @@ ${CLEANUP_CRON_SCHEDULE} /app/cleanup_tokens.sh >> /tmp/logs/cleanup.log 2>&1
26
  EOF
27
 
28
  echo "[entrypoint] Cleanup schedule: ${CLEANUP_CRON_SCHEDULE}"
29
- echo "[entrypoint] Cleanup schedule written to /tmp/crontabs/root" >&2
30
 
31
  # Start crond (busybox) with custom crontab directory
32
- if crond -c /tmp/crontabs -l 8 -L /tmp/logs/crond.log 2>/tmp/logs/crond_start_err.log; then
33
- echo "[entrypoint] crond started successfully" >&2
34
- else
35
- echo "[entrypoint] WARNING: crond failed to start (exit=$?), continuing without scheduled cleanup" >&2
36
- cat /tmp/logs/crond_start_err.log >&2 2>/dev/null
37
- fi
38
  echo "[entrypoint] crond started"
39
 
40
  # Wait for the API to be ready, then run the initial cleanup in background.
 
41
  (
42
  echo "[entrypoint] Waiting for API to be ready (polling localhost:7860)..."
43
  MAX_WAIT=120
@@ -56,8 +52,5 @@ echo "[entrypoint] crond started"
56
  /app/cleanup_tokens.sh >> /tmp/logs/cleanup.log 2>&1
57
  ) &
58
 
59
- echo "[entrypoint] About to exec cli-proxy-api..." >&2
60
- echo "[entrypoint] Binary exists: $(ls -la /app/cli-proxy-api 2>&1)" >&2
61
- echo "[entrypoint] Config exists: $(ls -la /app/config.yaml 2>&1)" >&2
62
  echo "[entrypoint] Launching cli-proxy-api..."
63
  exec /app/cli-proxy-api --config /app/config.yaml "$@"
 
4
  #
5
  # Environment variables:
6
  # CLEANUP_CRON_SCHEDULE - Cron schedule for token cleanup (default: "0 */6 * * *", every 6h)
7
+ # Examples:
8
+ # "0 */1 * * *" every hour
9
+ # "0 */6 * * *" every 6 hours (default)
10
+ # "0 2 * * *" daily at 2:00 AM
11
  # CLEANUP_STARTUP_DELAY - Seconds to wait after service is ready before first cleanup (default: 10)
12
  #
13
 
14
+ set -e
15
+
16
  echo "[entrypoint] Starting up at $(date)"
 
 
 
17
 
18
  CLEANUP_CRON_SCHEDULE="${CLEANUP_CRON_SCHEDULE:-0 */6 * * *}"
19
  CLEANUP_STARTUP_DELAY="${CLEANUP_STARTUP_DELAY:-10}"
20
 
21
  mkdir -p /tmp/logs /tmp/crontabs
 
22
 
23
  # Write crontab to /tmp (HuggingFace root filesystem is read-only)
24
  cat > /tmp/crontabs/root << EOF
 
27
  EOF
28
 
29
  echo "[entrypoint] Cleanup schedule: ${CLEANUP_CRON_SCHEDULE}"
 
30
 
31
  # Start crond (busybox) with custom crontab directory
32
+ crond -c /tmp/crontabs -l 8 -L /tmp/logs/crond.log
 
 
 
 
 
33
  echo "[entrypoint] crond started"
34
 
35
  # Wait for the API to be ready, then run the initial cleanup in background.
36
+ # This runs in a subshell so it doesn't block the main service from starting.
37
  (
38
  echo "[entrypoint] Waiting for API to be ready (polling localhost:7860)..."
39
  MAX_WAIT=120
 
52
  /app/cleanup_tokens.sh >> /tmp/logs/cleanup.log 2>&1
53
  ) &
54
 
 
 
 
55
  echo "[entrypoint] Launching cli-proxy-api..."
56
  exec /app/cli-proxy-api --config /app/config.yaml "$@"