gpt4 book ai didi

python - 如何永久 "wire"EC2 ip 地址到 virtualenv 中的 django

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:53:25 25 4
gpt4 key购买 nike

我正尝试按照 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

这能解决我的问题吗?如果不是我该怎么办?

最佳答案

您可以 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

关于python - 如何永久 "wire"EC2 ip 地址到 virtualenv 中的 django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28917887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com