mirror of
https://git.oceanpay.cc/danial/kami_apple_exchage.git
synced 2025-12-18 22:29:09 +00:00
- Create README.md for deployment instructions including environment requirements and setup steps. - Implement deploy.sh script for automated deployment of development and production environments. - Add combined Docker Compose configuration for frontend and backend services. - Include Redis configuration file for optimized memory management and persistence. - Update frontend Dockerfile to handle Next.js asset paths and static files. - Remove obsolete deployment files and configurations from frontend directory.
88 lines
2.0 KiB
Python
88 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
简单的Gunicorn测试脚本
|
|
用于验证Docker容器中的Gunicorn配置
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import signal
|
|
import time
|
|
import multiprocessing
|
|
from pathlib import Path
|
|
|
|
# 模拟Gunicorn配置
|
|
bind = "0.0.0.0:8000"
|
|
workers = max(1, multiprocessing.cpu_count() * 2 + 1)
|
|
worker_class = "uvicorn.workers.UvicornWorker"
|
|
worker_connections = 1000
|
|
timeout = 30
|
|
keepalive = 2
|
|
|
|
def test_imports():
|
|
"""测试必要的模块导入"""
|
|
try:
|
|
import uvicorn
|
|
import gunicorn
|
|
print("✅ Uvicorn和Gunicorn导入成功")
|
|
return True
|
|
except ImportError as e:
|
|
print(f"❌ 模块导入失败: {e}")
|
|
return False
|
|
|
|
def test_celery():
|
|
"""测试Celery应用"""
|
|
try:
|
|
from app.core.celery_app import get_celery_app
|
|
app = get_celery_app()
|
|
print("✅ Celery应用创建成功")
|
|
return True
|
|
except ImportError as e:
|
|
print(f"❌ Celery应用创建失败: {e}")
|
|
return False
|
|
|
|
def test_database():
|
|
"""测试数据库连接"""
|
|
try:
|
|
from app.core.database import get_database
|
|
db = get_database()
|
|
print("✅ 数据库连接配置成功")
|
|
return True
|
|
except ImportError as e:
|
|
print(f"❌ 数据库配置失败: {e}")
|
|
return False
|
|
|
|
def main():
|
|
"""主测试函数"""
|
|
print("🚀 开始测试Docker容器环境...")
|
|
|
|
tests = [
|
|
test_imports,
|
|
test_celery,
|
|
test_database,
|
|
]
|
|
|
|
passed = 0
|
|
failed = 0
|
|
|
|
for test in tests:
|
|
try:
|
|
if test():
|
|
passed += 1
|
|
else:
|
|
failed += 1
|
|
except Exception as e:
|
|
print(f"❌ 测试异常: {e}")
|
|
failed += 1
|
|
|
|
print(f"\n📊 测试结果: {passed} 通过, {failed} 失败")
|
|
|
|
if failed == 0:
|
|
print("🎉 所有测试通过! 容器准备就绪。")
|
|
return 0
|
|
else:
|
|
print("⚠️ 有测试失败,请检查配置。")
|
|
return 1
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main()) |