如果退出ssh 链接, 都会导致uwsgi进程关闭
这时, 我们需要进行管理软件管理uwsgi进行的运行, centos系统中我们采用 systemd, 让我们的项目变为系统服务
第一步:
首先 vim /etc/systemd/system/myproject.service
贴出我的代码:
[Unit]
Description=Fresh App Server
After=network.target
[Service]
User=root
#Group=root
WorkingDirectory=/root/Work/DailyFresh/Day_fresh/Fresh
ExecStart=/root/.local/share/virtualenvs/Day_fresh-KKzeP8YR/bin/uwsgi -i /root/Work/DailyFresh/Day_fresh/Fresh/uwsgi.ini
ExecStop=/root/.local/share/virtualenvs/Day_fresh-KKzeP8YR/bin/uwsgi --stop /root/Work/DailyFresh/Day_fresh/Fresh/uwsgi.pid
ExecReload=/root/.local/share/virtualenvs/Day_fresh-KKzeP8YR/bin/uwsgi --reload /root/Work/DailyFresh/Day_fresh/Fresh/uwsgi.pid
[Install]
WantedBy=multi-user.target
注意: ExecStart uwsgi的路径一定得是 虚拟环境下的uwsgi的路径, 如果不知道的话, whereis uwsgi 查找
接下来可以启动了
启动命令: systemctl start myproject.service (这里我的服务叫dayli_fresh)
重启命令: systemctl reload myproject.service (这里我的服务叫dayli_fresh)
停止命令: systemctl stop myproject.service (这里我的服务叫dayli_fresh)
https://www.jianshu.com/p/f14e6d03a18f?utm_source=oschina-app