"fix: 支持环境变量配置端口并修正生态配置"

This commit is contained in:
熊潇 2025-05-03 01:50:52 +08:00
parent 1141ddee3b
commit f5561f4fa9
2 changed files with 8 additions and 6 deletions

3
app.py
View File

@ -170,4 +170,5 @@ async def shutdown_event():
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=5005)
port = os.getenv("XHS_API_PORT", 5005)
uvicorn.run(app, host="0.0.0.0", port=port)

View File

@ -4,13 +4,14 @@ module.exports = {
apps: [
{
name: 'xhs-api-server',
script: 'app:app --host 0.0.0.0 --port ', // 替换为您的Python脚本路径
interpreter: 'uvicorn', // 替换为您的Python解释器路径
args: [PORT], // 传递端口参数
exec_mode: 'fork', // 使用fork模式
script: 'app.py', // 替换为您的Python脚本路径
interpreter: 'python', // 替换为您的Python解释器路径
instances: 1, // 启动一个实例
autorestart: true, // 自动重启
watch: false, // 不监视文件更改
env: {
XHS_API_PORT: PORT,
NODE_ENV: 'production',
},
},
],
};