部署flask项目gunicorn后systemd来管理server
systemctl start **.service 封装 workon venv 和 gunicorn -b 127.0.0.1:5000 manage:app 两个命令
not source venv/bin/activce和指定path启动guncorn
gunicorn的基本常用使用命令
- ps -ef | grep gunicorn
- gunicorn manage:app -b 127.0.0.1:5000
- killall gunicorn 直接全部kill所有 gunicorn进程
killall nginx
cd /etc/systemd/system
-
vi gunicorn.service
[Unit]
Description=Gunicorn instance to server sql_on_log
After=network.target[Service]
User=root
PrivateTmp=true
WorkingDirectory=/opt/essql/api
#Environment=“PATH=/home/python/venv/bin”
ExecStart=/home/python/venv/bin/gunicorn --bind 127.0.0.1:5000 manage:app[Install]
WantedBy=multi-user.target -
s