Update entrypoint.sh
Browse files- entrypoint.sh +21 -16
entrypoint.sh
CHANGED
|
@@ -2,33 +2,38 @@
|
|
| 2 |
#
|
| 3 |
# entrypoint.sh - Start crond for scheduled cleanup, then launch CLIProxyAPI
|
| 4 |
#
|
| 5 |
-
#
|
| 6 |
-
#
|
| 7 |
-
#
|
| 8 |
-
#
|
|
|
|
|
|
|
| 9 |
#
|
| 10 |
|
| 11 |
set -e
|
| 12 |
|
| 13 |
echo "[entrypoint] Starting up at $(date)"
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
EOF
|
| 22 |
|
| 23 |
-
|
| 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 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
exec /app/cli-proxy-api --config /app/config.yaml "$@"
|
|
|
|
| 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 |
+
# Examples:
|
| 8 |
+
# "0 */1 * * *" every hour
|
| 9 |
+
# "0 */6 * * *" every 6 hours (default)
|
| 10 |
+
# "0 2 * * *" daily at 2:00 AM
|
| 11 |
#
|
| 12 |
|
| 13 |
set -e
|
| 14 |
|
| 15 |
echo "[entrypoint] Starting up at $(date)"
|
| 16 |
|
| 17 |
+
# Default cleanup schedule: every 6 hours
|
| 18 |
+
CLEANUP_CRON_SCHEDULE="${CLEANUP_CRON_SCHEDULE:-0 */6 * * *}"
|
| 19 |
+
|
| 20 |
+
mkdir -p /tmp/logs /etc/crontabs
|
| 21 |
+
|
| 22 |
+
# Write crontab
|
| 23 |
+
cat > /etc/crontabs/root << EOF
|
| 24 |
+
# CLIProxyAPI invalid token cleanup
|
| 25 |
+
${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 |
|
| 30 |
# Start crond (busybox)
|
|
|
|
| 31 |
crond -l 8 -L /tmp/logs/crond.log
|
|
|
|
| 32 |
echo "[entrypoint] crond started"
|
|
|
|
| 33 |
|
| 34 |
+
# Run cleanup once immediately on startup (in background, so main service starts without waiting)
|
| 35 |
+
echo "[entrypoint] Running initial token cleanup in background..."
|
| 36 |
+
(/app/cleanup_tokens.sh >> /tmp/logs/cleanup.log 2>&1) &
|
| 37 |
+
|
| 38 |
+
echo "[entrypoint] Launching cli-proxy-api..."
|
| 39 |
exec /app/cli-proxy-api --config /app/config.yaml "$@"
|