Files
akmon/push-receiver-service/start.sh
2026-01-20 08:04:15 +08:00

68 lines
1.7 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
# 推送消息接收服务启动脚本
echo "🚀 启动推送消息接收服务..."
# 检查 Node.js 是否安装
if ! command -v node &> /dev/null; then
echo "❌ Node.js 未安装,请先安装 Node.js"
exit 1
fi
# 检查是否在正确的目录
if [ ! -f "package.json" ]; then
echo "❌ 请在 push-receiver-service 目录中运行此脚本"
exit 1
fi
# 安装依赖
echo "📦 安装依赖包..."
npm install
# 检查环境配置
if [ ! -f ".env" ]; then
echo "⚠️ 未找到 .env 文件,复制模板..."
if [ -f ".env.supabase" ]; then
cp .env.supabase .env
echo "📋 已复制 .env.supabase 为 .env请编辑配置"
echo " - SUPABASE_URL: 您的 Supabase 项目 URL"
echo " - SUPABASE_SERVICE_ROLE_KEY: 您的 Service Role Key"
echo " - API_KEY: 自定义 API 密钥"
read -p "是否已配置完成环境变量?(y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "❌ 请先配置环境变量再启动服务"
exit 1
fi
else
echo "❌ 未找到环境配置模板文件"
exit 1
fi
fi
# 初始化数据库
echo "🗄️ 初始化 Supabase 数据库..."
node setup-supabase.js
if [ $? -ne 0 ]; then
echo "❌ 数据库初始化失败,请检查配置"
exit 1
fi
# 运行测试
echo "🧪 运行基础测试..."
node test.js
if [ $? -ne 0 ]; then
echo "⚠️ 测试有错误,但继续启动服务..."
fi
# 启动服务
echo "🚀 启动推送消息接收服务..."
echo "📍 服务将在 http://localhost:3001 启动"
echo "💡 按 Ctrl+C 停止服务"
echo ""
node supabase-server.js