Create entrypoint.sh
Browse files- entrypoint.sh +34 -0
entrypoint.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
#
|
| 3 |
+
# entrypoint.sh - Start crond for scheduled cleanup, then launch CLIProxyAPI
|
| 4 |
+
#
|
| 5 |
+
# This script:
|
| 6 |
+
# 1. Sets up the crontab for periodic token cleanup
|
| 7 |
+
# 2. Starts busybox crond in background
|
| 8 |
+
# 3. Launches the main cli-proxy-api service in foreground
|
| 9 |
+
#
|
| 10 |
+
|
| 11 |
+
set -e
|
| 12 |
+
|
| 13 |
+
echo "[entrypoint] Starting up at $(date)"
|
| 14 |
+
|
| 15 |
+
# Write crontab for token cleanup
|
| 16 |
+
# Runs every 6 hours: at 0:00, 6:00, 12:00, 18:00
|
| 17 |
+
mkdir -p /etc/cron.d
|
| 18 |
+
cat > /etc/crontabs/root << 'EOF'
|
| 19 |
+
# CLIProxyAPI invalid token cleanup - runs every 6 hours
|
| 20 |
+
0 */6 * * * /app/cleanup_tokens.sh >> /tmp/logs/cleanup.log 2>&1
|
| 21 |
+
EOF
|
| 22 |
+
|
| 23 |
+
# Ensure log directory exists
|
| 24 |
+
mkdir -p /tmp/logs
|
| 25 |
+
|
| 26 |
+
# Start crond (busybox)
|
| 27 |
+
echo "[entrypoint] Starting crond..."
|
| 28 |
+
crond -l 8 -L /tmp/logs/crond.log
|
| 29 |
+
|
| 30 |
+
echo "[entrypoint] crond started"
|
| 31 |
+
echo "[entrypoint] Launching cli-proxy-api..."
|
| 32 |
+
|
| 33 |
+
# Hand off to main process (becomes PID 1)
|
| 34 |
+
exec /app/cli-proxy-api --config /app/config.yaml "$@"
|