Files
zhuiguang-ai/scripts/entrypoint-cron.sh
T

39 lines
1.1 KiB
Bash

#!/bin/sh
# =============================================================================
# 追光AI CRON 容器启动入口
# - 用 supercronic 调度 /app/crontab.txt 里的任务
# - 跟 host cron 行为一致,但完全在容器内
# =============================================================================
set -e
cd /app
# Seed data volume if empty
if [ ! -f /app/data/bot-characters.json ] && [ -d /app/data-seed ]; then
echo "[entrypoint] Seeding data volume..."
cp -r /app/data-seed/* /app/data/
fi
# 1) .env 校验
if [ ! -f /app/.env ]; then
echo "[entrypoint-cron] FATAL: /app/.env not found. Mount .env file into container."
exit 1
fi
# 2) crontab 文件校验
if [ ! -f /app/crontab.txt ]; then
echo "[entrypoint-cron] FATAL: /app/crontab.txt not found. Mount crontab into container."
exit 1
fi
# 3) supercronic 启动
echo "[entrypoint-cron] Starting supercronic..."
echo "[entrypoint-cron] crontab:"
sed 's/^/ /' /app/crontab.txt
# -prometheus-listen-address 可选 (开监控)
# -split-logs 把 stdout/stderr 拆开
exec /usr/local/bin/supercronic-linux-amd64 \
-prometheus-listen-address 0.0.0.0:8310 \
/app/crontab.txt