ohmyapi commited on
Commit
c654bd8
·
verified ·
1 Parent(s): f31dea7

test: minimal entrypoint - just echo and exec

Browse files
Files changed (1) hide show
  1. entrypoint.sh +2 -62
entrypoint.sh CHANGED
@@ -1,63 +1,3 @@
1
  #!/bin/sh
2
- #
3
- # entrypoint.sh - Start crond for scheduled cleanup, then launch CLIProxyAPI
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)"
11
-
12
- CLEANUP_CRON_SCHEDULE="${CLEANUP_CRON_SCHEDULE:-0 */6 * * *}"
13
- CLEANUP_STARTUP_DELAY="${CLEANUP_STARTUP_DELAY:-10}"
14
- CRON_OK=0
15
-
16
- mkdir -p /tmp/logs /tmp/crontabs
17
-
18
- # Write crontab to /tmp (HuggingFace root filesystem is read-only)
19
- cat > /tmp/crontabs/root << EOF
20
- ${CLEANUP_CRON_SCHEDULE} /app/cleanup_tokens.sh >> /tmp/logs/cleanup.log 2>&1
21
- EOF
22
-
23
- echo "[entrypoint] Cleanup schedule: ${CLEANUP_CRON_SCHEDULE}"
24
-
25
- # Try crond; if it fails (e.g. permission issues), fall back to a sleep loop
26
- if crond -c /tmp/crontabs -l 8 -L /tmp/logs/crond.log 2>/dev/null; then
27
- echo "[entrypoint] crond started"
28
- CRON_OK=1
29
- else
30
- echo "[entrypoint] WARNING: crond failed, will use sleep-loop fallback for scheduled cleanup"
31
- fi
32
-
33
- # Background: wait for API ready, run initial cleanup, then optionally loop
34
- (
35
- echo "[entrypoint] Waiting for API to be ready (polling localhost:7860)..."
36
- MAX_WAIT=120
37
- WAITED=0
38
- while ! wget -q -O /dev/null http://localhost:7860/ 2>/dev/null; do
39
- sleep 2
40
- WAITED=$((WAITED + 2))
41
- if [ "$WAITED" -ge "$MAX_WAIT" ]; then
42
- echo "[entrypoint] WARNING: API did not become ready after ${MAX_WAIT}s, running cleanup anyway"
43
- break
44
- fi
45
- done
46
- echo "[entrypoint] API ready (waited ${WAITED}s). Sleeping ${CLEANUP_STARTUP_DELAY}s before cleanup..."
47
- sleep "$CLEANUP_STARTUP_DELAY"
48
- echo "[entrypoint] Running initial token cleanup..."
49
- /app/cleanup_tokens.sh >> /tmp/logs/cleanup.log 2>&1
50
-
51
- # If crond failed, run cleanup in a sleep loop (every 6 hours = 21600s)
52
- if [ "$CRON_OK" = "0" ]; then
53
- echo "[entrypoint] Starting sleep-loop cleanup (every 6h)..."
54
- while true; do
55
- sleep 21600
56
- echo "[cleanup-loop] Running scheduled cleanup at $(date)"
57
- /app/cleanup_tokens.sh >> /tmp/logs/cleanup.log 2>&1
58
- done
59
- fi
60
- ) &
61
-
62
- echo "[entrypoint] Launching cli-proxy-api..."
63
- exec /app/cli-proxy-api --config /app/config.yaml "$@"
 
1
  #!/bin/sh
2
+ echo "[entrypoint] starting"
3
+ exec /app/cli-proxy-api --config /app/config.yaml