centos7 uwsgi 加入系统服务
阅读原文时间:2023年07月09日阅读:1

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

具体配置方法如下:

1. 创建配置文件

vim /etc/systemd/system/server_uwsgi.service

2. 填入以下内容

[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

3. 将该服务加入到systemd中

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

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

systemctl stop server_uwsgi.service 关闭uwsgi服务

systemctl start server_uwsgi.service 开启uwsgi服务

systemctl restart server_uwsgi.service 重启uwsgi服务

systemctl enable server_uwsgi.service 设置开机自启

注意事项:

如果uwsgi配置文件中配置了 daemonize=/path/uwsgi.log (uwsgi服务以守护进程运行)
会导致sytemctl启动时多次重启而导致启动失败
需改为 logto=/path/uwsgi.log
————————————————
原文链接:https://blog.csdn.net/sinat_41292836/article/details/102894110

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章