我试图按照http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html上的教程进行操作。我正在亚马逊EC2上使用ubuntu 14.4实例。我试图部署一个我用python3在本地开发的django应用程序。到目前为止,只要我手动ssh in,打开virtualenv,然后打开uwsgi,使用:
workon env1
uwsgi --ini /home/ubuntu/mysite_uwsgi.ini
但是我注意到,当我今天早上尝试向应用程序发送请求时,我得到了:
errno 5 input/output error
这解决了我手动sshing并执行上面的2行。我不明白这是如何工作的,但不知何故,我的virtualenv和uwsgi在我注销后被停用了。我需要让它们保持活动状态,以便所有请求都能汇集到我的应用程序中。我不知道该怎么做。在上面的tut之后,我将/etc/rc.local修改为:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
workon myenv
uwsgi --ini /home/ubuntu/mysite_uwsgi.ini
exit 0
这会解决我的问题。如果不是我该怎么办?
答案 0 :(得分:1)
你可以daemonize这个过程:
env = DJANGO_SETTINGS_MODULE=mysite.settings # set an environment variable
pidfile = /tmp/project-master.pid # create a pidfile
harakiri = 20 # respawn processes taking more than 20 seconds
limit-as = 128 # limit the project to 128 MB
max-requests = 5000 # respawn processes after serving 5000 requests
"uwsgi --ini uwsgi.ini --daemonize=/var/log/yourproject.log # background the
答案 1 :(得分:0)
如果您已经按照文档的其余部分进行操作,并准备好在" emperor"模式,在exit 0
之前将其添加到/etc/rc.local:
/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data