awesome/start.sh
cheney 381e6a780d
Some checks failed
Build and Deploy / build (push) Successful in 10s
Build and Deploy / deploy (push) Failing after 45s
feat: 版本时间+8区、首页随机卡片点击进详情;chore: 优雅关闭DuckDB、start.sh改用docker stop
2026-09-01 11:40:21 +08:00

53 lines
1.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
# Awesome Index 重启脚本(使用已构建的镜像,纯 docker run无 compose
DEPLOY_PATH="$(cd "$(dirname "$0")" && pwd)"
cd "$DEPLOY_PATH"
# 检查 .env 文件
if [ ! -f .env ]; then
if [ -f .env.example ]; then
cp .env.example .env
echo "已从 .env.example 创建 .env请检查 SESSION_SECRET / ADMIN_INIT_PASSWORD / AI_INGEST_KEY"
else
echo "错误: 缺少 .env 文件"
exit 1
fi
fi
# 停止并删除旧容器(先优雅停止,让应用关闭 DuckDB 完成 checkpoint
echo "停止旧容器..."
docker stop awesome-index 2>/dev/null || true
docker rm awesome-index 2>/dev/null || true
# 用新镜像启动容器
echo "启动 Awesome Index..."
docker run -d \
--name awesome-index \
--restart unless-stopped \
-p 3000:3000 \
-v "$DEPLOY_PATH/data:/app/data" \
--env-file .env \
awesome-index:latest
# 健康检查
echo "等待服务就绪..."
sleep 5
MAX_RETRIES=10
RETRY_COUNT=0
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
if curl -sf http://localhost:3000/healthz > /dev/null 2>&1; then
echo "✓ 服务已启动: http://localhost:3000"
echo ""
echo "管理后台: http://localhost:3000/admin"
exit 0
fi
RETRY_COUNT=$((RETRY_COUNT + 1))
sleep 2
done
echo "✗ 服务启动失败,请检查日志: docker logs awesome-index"
exit 1