FreeLLMAPI / start.sh
lydgs's picture
Update start.sh
b571b69 verified
Raw
History Blame Contribute Delete
920 Bytes
#!/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