背景生产环境使用nginx+uwsgi+django部署web服务。这里需要启动和停止uwsgi。简单的处理方式,直接在命令行启动和杀死即可。uwsgi服务,但是为了更安全方便的管理uwsgi服务,将uwsgi配置到systemd服务中,同时实现自启动功能;另外,由于supervisor不支持python3,所以没有使用supervisor来管理uwsgi服务;具体配置方法如下:step1.创建配置文件/etc/systemd/system/server_uwsgi.servicestep2。填写以下内容[Unit]Description=HTTPInterfaceServerAfter=syslog.target[Service]KillSignal=SIGQUITExecStart=/usr/bin/uwsgi--ini/path/uwsgi.iniRestart=alwaysType=notifyNotifyAccess=allStandardError=syslog[Install]WantedBy=多用户.targetstep3。将服务添加到systemdsystemctlenable/etc/systemd/system/server_uwsgi.service然后就可以通过systemctl控制服务了重启uwsgi服务注意:如果在uwsgi配置文件中配置了daemonize=/path/uwsgi.log(uwsgi服务是一个daemon进程运行)会导致sytemctl在启动时多次重启,导致启动失败。需要改为logto=/path/uwsgi.log
