Spaces:
Sleeping
Sleeping
File size: 920 Bytes
7aeccb2 d068948 7aeccb2 b571b69 22a48f5 b571b69 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #!/bin/bash
set -e
echo "==> Running database restore..."
python3 /app/scripts/restore_from_dataset.py
echo "==> Starting supervisor in background..."
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf &
echo "==> Waiting for FreeLLMAPI to create database file..."
# 最多等待 30 秒,直到数据库文件出现
for i in {1..30}; do
if [ -f "/app/server/data/freeapi.db" ]; then
echo "==> Database file detected. Running initial backup..."
python3 /app/scripts/backup_to_dataset.py && echo "Initial backup succeeded." || echo "Initial backup failed, will retry via cron"
break
fi
sleep 1
done
# 如果 30 秒后数据库仍未出现,记录警告但不影响服务
if [ ! -f "/app/server/data/freeapi.db" ]; then
echo "==> WARNING: Database file not created after 30 seconds. Backup skipped."
fi
# 保持前台进程运行(supervisor 已在后台)
wait |