如何永久 "wire" 一个 EC2 ip 地址到 virtualenv 中的 django
How to permanently "wire" an EC2 ip address to django in a virtualenv
我正在尝试按照 http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html 上的教程进行操作。我正在使用亚马逊 EC2 上的 ubuntu 14.4 实例。我正在尝试部署我在本地使用 python3 开发的 Django 应用程序。到目前为止,只要我手动 ssh in,打开 virtualenv,然后打开 uwsgi,我就可以按照 tut 运行应用程序,使用:
workon env1
uwsgi --ini /home/ubuntu/mysite_uwsgi.ini
但是我注意到,当我今天早上尝试向该应用程序发送请求时,我得到了:
errno 5 input/output error
这已经解决了我手动 sshing 并执行上面的 2 行。我不明白这是如何工作的,但不知何故,我的 virtualenv 和 uwsgi 在我注销后被停用了。我需要让它们保持活动状态,以便所有请求都可以汇集到我的应用程序。我不知道该怎么做。按照上面的说明,我将 /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
这能解决我的问题吗。如果不是我该怎么办?
如果您已经阅读了文档的其余部分并准备好在 "emperor" 模式下 运行,请在 exit 0
之前将其添加到 /etc/rc.local:
/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data
您可以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
我正在尝试按照 http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html 上的教程进行操作。我正在使用亚马逊 EC2 上的 ubuntu 14.4 实例。我正在尝试部署我在本地使用 python3 开发的 Django 应用程序。到目前为止,只要我手动 ssh in,打开 virtualenv,然后打开 uwsgi,我就可以按照 tut 运行应用程序,使用:
workon env1
uwsgi --ini /home/ubuntu/mysite_uwsgi.ini
但是我注意到,当我今天早上尝试向该应用程序发送请求时,我得到了:
errno 5 input/output error
这已经解决了我手动 sshing 并执行上面的 2 行。我不明白这是如何工作的,但不知何故,我的 virtualenv 和 uwsgi 在我注销后被停用了。我需要让它们保持活动状态,以便所有请求都可以汇集到我的应用程序。我不知道该怎么做。按照上面的说明,我将 /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
这能解决我的问题吗。如果不是我该怎么办?
如果您已经阅读了文档的其余部分并准备好在 "emperor" 模式下 运行,请在 exit 0
之前将其添加到 /etc/rc.local:
/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data
您可以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