Gunicorn 启动django服务

安装的所有依赖 保存到requirements.txt中 :

复制代码
pip freeze > requirements.txt

先检查 Gunicorn 进程:

css 复制代码
ps aux | grep gunicorn   lsof -i :8080

杀死进程

bash 复制代码
sudo kill 400136 

激活虚拟环境:

bash 复制代码
source venv/bin/activate    source .venv/bin/activate

安装依赖:

复制代码
pip install -r requirements.txt

Gunicorn 后台运行方法

方法一:用 & 放到后台

bash 复制代码
gunicorn medical_companion_server.wsgi:application --bind 0.0.0.0:8000 &
  • 这种方式会让 Gunicorn 进程在后台运行,退出当前终端后进程可能会消失(不稳定,重启/掉线就没了)。

方法二:使用 nohup(推荐)

bash 复制代码
nohup gunicorn medical_companion_server.wsgi:application --bind 0.0.0.0:8000 > gunicorn.log 2>&1 &
  • nohup 让进程和终端断开,掉线后服务也在。

  • 日志会输出到 gunicorn.log 文件。

相关推荐
fliter6 小时前
在 Async Rust 中实现请求合并(Request Coalescing)
后端
fliter6 小时前
一个让我调试一周的 Rust match 陷阱
后端
一只大袋鼠7 小时前
SpringBoot 初学阶段知识点汇总(一)
spring boot·笔记·后端
Rust研习社7 小时前
Rust 官方拟定 LLM 政策,防止 LLM 污染开源社区?
开发语言·后端·ai·rust·开源
无风听海7 小时前
ASP.NET Core Minimal API 深度解析
后端·asp.net
IT_陈寒7 小时前
Java的finally块竟然不是你想的那个finally!
前端·人工智能·后端
zb200641207 小时前
Laravel4.x核心特性全解析
spring boot·后端·php·laravel
techdashen8 小时前
在 Async Rust 中实现请求合并(Request Coalescing)
开发语言·后端·rust
lzp07918 小时前
C#如何优雅处理引用类型的深拷贝(贰)
spring boot·后端·ui