Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

ubuntu 16.04 uwsgi自启动

$
0
0

网上的关于uwsgi的自启动的方法还是挺多的,具体搜索一下就知道了,这里简单的写一下官方推荐的方法,通过systemd启动服务。如果用这个方法需要首先确定systemd的版本大于211。

通过下面的命令获取systemd版本信息:

root@mars:/etc/systemd/system# systemctl --version systemd 229 +PAM +AUDIT +SElinux +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN

按照官方的文档编写service文件,放入/etc/systemd/system目录下然后执行

systemctl start emperor.uwsgi.service即可启动服务。service文件如下: [Unit] Description=uWSGI Emperor After=syslog.target [Service] ExecStart=/usr/local/bin/uwsgi --ini /var/www/html/project/uwsgi.ini # Requires systemd version 211 or newer RuntimeDirectory=uwsgi Restart=always KillSignal=SIGQUIT Type=notify StandardError=syslog NotifyAccess=all [Install] WantedBy=multi-user.target

这个脚本需要注意两个地方,一个是uwsgi的可执行文件路径,另外一个是uwsgi.ini配置文件路径。可执行文件路径可以通过whois uwsgi获取。

不过需要注意的是,如果此时重启系统服务并不会自动启动:

root@mars:~# systemctl status emperor.uwsgi.service ● emperor.uwsgi.service - uWSGI Emperor Loaded: loaded (/etc/systemd/system/emperor.uwsgi.service; disabled; vendor preset: enabled) Active: inactive (dead)

需要通过enable 来设置服务自动启动

root@mars:~# systemctl enable emperor.uwsgi.service Created symlink from /etc/systemd/system/multi-user.target.wants/emperor.uwsgi.service to /etc/systemd/system/emperor.uwsgi.service.

此时查看服务状态就是enabled了

root@mars:~# systemctl status emperor.uwsgi.service ● emperor.uwsgi.service - uWSGI Emperor Loaded: loaded (/etc/systemd/system/emperor.uwsgi.service; enabled; vendor preset: enabled) Active: inactive (dead)

原创文章,转载请注明:转载自obaby@mars

本文标题: 《ubuntu 16.04 uwsgi自启动》

本文链接地址: http://www.h4ck.org.cn/2018/12/ubuntu-16-04-uwsgi%e8%87%aa%e5%90%af%e5%8a%a8/


Viewing all articles
Browse latest Browse all 11063

Trending Articles