您好,欢迎来到微智科技网。
搜索
您的当前位置:首页centos7 配置 uwsgi 系统服务(systemd)

centos7 配置 uwsgi 系统服务(systemd)

来源:微智科技网

背景生产环境中采用nginx + uwsgi + django 来部署web服务,这里需要实现uwsgi的启动和停止,简单的处理方式可以直接在命令行中启动和kill掉uwsgi服务,但为了更安全、方便的管理uwsgi服务,配置uwsgi到systemd服务中,同时实现开启自启的功能;
另,鉴于supervisor不支持python3,没采用supervisor来管理uwsgi服务;

具体配置方法如下:

step1. 创建配置文件

/etc/systemd/system/server_uwsgi.service

step2. 填入以下内容

[Unit]
Description=HTTP Interface Server
After=syslog.target

[Service]
KillSignal=SIGQUIT
ExecStart=/usr/bin/uwsgi --ini /path/uwsgi.ini
Restart=always
Type=notify
NotifyAccess=all
StandardError=syslog

[Install]
WantedBy=multi-user.target

step3. 将该服务加入到systemd中

systemctl enable /etc/systemd/system/server_uwsgi.service

然后就可以通过systemctl来控制服务的启停

systemctl stop server_uwsgi.service 关闭uwsgi服务
systemctl start server_uwsgi.service 开启uwsgi服务
systemctl restart server_uwsgi.service 重启uwsgi服务

注意事项:

如果uwsgi配置文件中配置了 daemonize=/path/uwsgi.log (uwsgi服务以守护进程运行)
会导致sytemctl启动时多次重启而导致启动失败
需改为 logto=/path/uwsgi.log

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 7swz.com 版权所有 赣ICP备2024042798号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务