awesome/start.sh

47 lines
1.1 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
DEPLOY_PATH="$(cd "$(dirname "$0")" && pwd)"
cd "$DEPLOY_PATH"
# 检查 .env 文件
if [ ! -f .env ]; then
echo "错误: 缺少 .env 文件,请从 .env.example 复制并修改"
exit 1
fi
# 安装依赖
echo "安装依赖..."
npm ci --omit=dev --no-audit --no-fund
# 停止旧进程
echo "停止旧进程..."
pkill -f "node src/index.js" 2>/dev/null || true
sleep 1
# 启动服务
echo "启动 Awesome Index..."
nohup node src/index.js > logs/app.log 2>&1 &
# 健康检查
echo "等待服务就绪..."
sleep 2
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"
echo "默认账号: admin / (见 .env 中的 ADMIN_INIT_PASSWORD)"
exit 0
fi
RETRY_COUNT=$((RETRY_COUNT + 1))
sleep 2
done
echo "✗ 服务启动失败,请检查日志: tail -50 logs/app.log"
exit 1