"refactor(backend): 移除未使用的redis、socket.io和sqlite3依赖"包括:

- `backend/.env.production`:生产环境变量配置
- `backend/ecosystem.config.js`:PM2生态系统配置文件
- `scripts/nginx-aijianhua.conf`:Nginx配置文件
- `scripts/server-deploy.sh`:服务器部署脚本
- `scripts/sync-to-server.sh`:代码同步脚本
- `docs/生产环境部署指南.md`:生产环境部署指南文档

同时移除了`package.json`中不再使用的依赖项:- `redis`- `socket.io`
- `sqlite3`这些更改将有助于简化生产环境的部署流程,并确保服务能够稳定运行。```
This commit is contained in:
2025-09-11 17:05:14 +08:00
parent 28c7b17767
commit a10df5928e
36 changed files with 520 additions and 3 deletions

36
backend/.env.production Normal file
View File

@@ -0,0 +1,36 @@
# 爱鉴花生产环境配置
# 部署到CentOS服务器时使用
NODE_ENV=production
PORT=3330
# 数据库配置 - 生产环境MySQL
DB_HOST=129.211.213.226
DB_PORT=9527
DB_USER=root
DB_PASSWORD=aiotAiot123!
DB_NAME=xlxumudata
# JWT配置
JWT_SECRET=your-production-jwt-secret-key-change-this-in-production
JWT_EXPIRE=7d
# 文件上传配置
UPLOAD_MAX_SIZE=50MB
UPLOAD_PATH=./uploads
# CORS配置 - 生产环境域名
CORS_ORIGIN=https://your-domain.com,https://wapi.aijianhua.com
# 日志配置
LOG_LEVEL=info
LOG_FILE=/data/nodejs/aijianhua/logs/app.log
# 性能配置
NODE_OPTIONS=--max-old-space-size=4096
# Swagger配置生产环境启用
SWAGGER_ENABLED=true
SWAGGER_TITLE=爱鉴花API文档
SWAGGER_DESCRIPTION=爱鉴花小程序后端API接口文档
SWAGGER_VERSION=1.0.0

View File

@@ -0,0 +1,35 @@
// PM2生态系统配置文件
// 用于生产环境部署
module.exports = {
apps: [{
name: 'aijianhua-backend',
script: './app.js',
instances: 'max',
exec_mode: 'cluster',
env: {
NODE_ENV: 'production',
PORT: 3330,
NODE_OPTIONS: '--max-old-space-size=4096'
},
env_production: {
NODE_ENV: 'production',
PORT: 3330
},
// 日志配置
log_file: '/data/nodejs/aijianhua/logs/combined.log',
out_file: '/data/nodejs/aijianhua/logs/out.log',
error_file: '/data/nodejs/aijianhua/logs/error.log',
// 进程管理
max_memory_restart: '1G',
watch: false,
ignore_watch: ['node_modules', 'logs', 'uploads'],
// 重启策略
autorestart: true,
restart_delay: 3000,
// 高级配置
node_args: '--harmony',
merge_logs: true,
time: true
}]
};

View File

@@ -22,9 +22,6 @@
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"mysql2": "^3.6.0",
"redis": "^4.6.8",
"socket.io": "^4.7.2",
"sqlite3": "^5.1.7",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^4.6.3",
"validator": "^13.11.0",