繁体   English   中英

我已经配置了我的 uwsgi.ini 文件并且它在 nohup 上工作正常。 如何在启动时自动启动 uwsgi?

[英]I have configured my uwsgi.ini file and its working fine with nohup. How can auto start uwsgi on boot?

这是我的 uesgi.conf 代码

description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]
respawn

env UWSGI=/usr/local/bin/uwsgi
env LOGTO=/var/log/uwsgi.log

exec $UWSGI --master --emperor /home/ubuntu/socialtalks/config --die-on-term --uid socialtalks --gid www-data --logto $LOGTO

这里是ini文件配置。

uwsgi.ini

    [uwsgi]
# variables
#projectname = thesocialtalks
#base = /home/ubuntu/thesocialtalks

# configuration
#master = true
env = /home/ubuntu/socialtalks
#pythonpath = %(base)
#chdir = %(base)
env = DJANGO_SETTINGS_MODULE=%(projectname).settings.production
#module = thesocialtalks.wsgi:application
#socket = /tmp/%(projectname).sock

# mysite_uwsgi.ini file
[uwsgi]
projectname = socialtalks
pcre = true
base = /home/ubuntu/socialtalks
# Django-related settings
# the base directory (full path)
#chdir           = /home/ubuntu/socialtalks
chdir = %(base)
# Django's wsgi file
#module          = socialtalks.wsgi
module           = %(projectname).wsgi
# the virtualenv (full path)
#home            = /home/admin5/test/thesocialtalks_final/thesocialtalks
plugin = python37
# process-related settings
# master
master          = true
enable-threads = true

# maximum number of worker processes
processes       = 10
# the socket (use the full path to be safe
#socket          = /home/ubuntu/socialtalks/mysite.sock
socket = /tmp/%(projectname).sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
uid = www-data
gid = www-data

# clear environment on exit
vacuum          = true

我正在使用命令运行脚本

nohup uwsgi --ini config/uwsgi.ini &

如何在系统启动后自动启动我的 uwsgi?

您绝对可以安装主管,它允许您运行任何程序并不断检查它的状态以确保程序正在运行。

[program:test]
autostart = true
stopsignal=QUIT
user=root
command=uwsgi --master --workers  5 --disable-logging --socket 127.0.0.1:8888
--module web --callable app
priority=1
redirect_stderr=true
stdout_logfile = /data/log

要设置主管,您可以查看此文档: https : //www.programmersought.com/article/97941378800/并在启动时启动主管,您可以键入以下命令:

# Make sure Supervisor comes up after a reboot.
sudo systemctl enable supervisor

# Bring Supervisor up right now.
sudo systemctl start supervisor

要获取更多信息,您可以转到下一个线程: https : //unix.stackexchange.com/questions/281774/ubuntu-server-16-04-cannot-get-supervisor-to-start-automatically

我不是 UWSGI 的专家,但我似乎有很多使用这种组合使用 Django 和 UWSGI 的存储库。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM