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
相关推荐
岁月如歌 2020-07-27
lreis00 2020-06-29
89403969 2020-06-12
ZhaoMengjiao 2020-06-09
87193750 2020-05-30
咻咻ing 2020-05-17
eightbrother 2020-05-05
87254055 2020-04-14
ZhaoMengjiao 2020-03-28
ZhaoMengjiao 2020-03-08
89403969 2020-03-04
89403969 2020-03-04
87193750 2020-02-24
85407718 2020-02-09
eightbrother 2020-01-02
vanturman 2019-12-26
山顶冻人 2019-12-25
aolishuai 2019-12-13
89403969 2019-12-11