独角兽总是在http://127.0.0.1:8000上听

问题描述 投票:1回答:2

我已经在webfaction上设置了django应用程序,现在我正尝试使用Guicorn服务我的应用程序。当我设置文件并进行配置时,除似乎始终以127.0.0.1:8000监听外,其他所有东西似乎都在工作。

我的配置如下。

supervisord.conf

[unix_http_server]
file=/home/devana/tmp/supervisor.sock

[supervisord]
logfile=/home/devana/tmp/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/home/devana/webapps/devana/etc/supervisord.pid

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///home/devana/tmp/supervisor.sock
[include]
files = /home/devana/webapps/devana/etc/supervisord/*.ini

Supervisor.ini

[program:devana]
command=/home/devana/webapps/devana/scripts/start_server
directory=/home/devana/webapps/devana/csiop/
user=devana
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile = /home/devana/tmp/gunicorn_supervisor.log

启动服务器

NAME="devana"                                      # Name of the application
DJANGODIR=/home/devana/webapps/devana/csiop        # Django project directory
SOCKFILE=/home/devana/webapps/devana/run/gunicorn.sock # we will communicte using this 
                                                       unix socket
USER=devana                                        # the user to run as
NUM_WORKERS=3                    # how many worker processes should     Gunicorn spawn 
DJANGO_SETTINGS_MODULE=devana.settings.production  # which settings should Django use
DJANGO_WSGI_MODULE=devana.wsgi                     # WSGI module name
BIND=2.14.5.58:31148 (IP and the port number provided by webfaction in this place)

echo "Starting $NAME as `whoami`"

# Activate the virtual environment
cd $DJANGODIR
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH

# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR

# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec /home/devana/webapps/devana/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
    --name $NAME \
    --workers $NUM_WORKERS \
    --user=$USER \
    --log-level=debug \
    --bind=$BIND

现在,当我键入'../bin/Supervisord'命令时,guicorn正在启动,但它监听的是127.0.0.1:8000,而不是我提供的绑定变量,并且我无法使用http://mywebsite.com打开我的网站。

有人可以指出我在做什么错

gunicorn supervisord webfaction
2个回答
0
投票

我发现了问题。我没有使用包含IP和端口的BIND变量,而是将它们分为两个不同的变量,并使用--bind = $ IP:$ PORT。似乎有效


0
投票

如果gunicon侦听127.0.0.1:8000,则可能是默认设置,因为无法应用提供的-b / --bind参数。

© www.soinside.com 2019 - 2024. All rights reserved.