错误(没有这样的文件)nginx + uwsgi + supervisor + Django

时间:2017-08-16 15:48:20

标签: django nginx uwsgi supervisor

逗人, 使用nginx + uwsgi + supervisor部署Django项目时出现问题。在Ubuntu上使用命令方法时,一切正常,但在supervisord中失败,希望有人可以帮助我。

适用于:

sudo uwsgi --http :8001 --chdir /home/ubuntu/mysite2 --module mysite2.wsgi

在主管中启动程序时出现错误消息:

    root@ip-172-31-9-54:~# sudo supervisorctl -c /etc/supervisord.conf restart mysite2
    mysite2: ERROR (not running)
    mysite2: ERROR (no such file)

mysite2_uwsgi.ini:


    [uwsgi]

    # Django-related settings

    #http = :8001
    socket = /home/ubuntu/mysite2/mysocket.sock
    chdir           = /home/ubuntu/mysite2
    wsgi-file = mysite2/wsgi.py
    touch-reload = /home/ubuntu/mysite2/reload
    processes   = 2
    threads     = 4
    chmod-socket    = 664
    chown-socket = ubuntu:www-data
    vacuum          = true  

/etc/supervisord.conf


    [program:mysite2]
    command=/usr/local/bin/uwsgi --ini /home/ubuntu/mysite2/mysite2_uwsgi.ini    ;  ddd
    ;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
    ;numprocs=1                    ; number of processes copies to start (def 1)
    directory=/home/ubuntu/mysite2       ; directory to cwd to before exec (def no cwd)
    ;umask=022                     ; umask for process (default None)
    ;priority=999                  ; the relative start priority (default 999)
    autostart=true                ; start at supervisord start (default: true)
    startsecs=0                   ; # of secs prog must stay up to be running (def. 1)
    ;startretries=3                ; max # of serial start failures when starting (default 3)
    autorestart=true        ; when to restart if exited after running (def: unexpected)
    ;exitcodes=0,2                 ; 'expected' exit codes used with autorestart (default 0,2)
    ;stopsignal=QUIT               ; signal used to kill process (default TERM)
    stopwaitsecs=0               ; max num secs to wait b4 SIGKILL (default 10)
    ;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
    ;killasgroup=false             ; SIGKILL the UNIX process group (def false)
    ;user=chrism                   ; setuid to this UNIX account to run the program
    ;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
    ;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
    ;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    ;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
    ;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
    ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
    ;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
    ;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    ;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
    ;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
    ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
    ;environment=A="1",B="2"       ; process environment additions (def no adds)
    ;serverurl=AUTO                ; override serverurl computation (childutils)

settings.py

    import os
    from django.core.wsgi import get_wsgi_application
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite2.settings")
    application = get_wsgi_application()

/etc/nginx/sites-available/mysite2.conf


    server {
        listen      80;
        server_name www.XXXXX.com;
        charset     utf-8;

        client_max_body_size 75M;

        location /static {
            alias /home/unbtun/mysite2/static/;
        }

        location / {
            uwsgi_pass unix:///home/ubuntu/mysite2/mysocket.sock;
            include /etc/nginx/uwsgi_params;
        }
    }

2 个答案:

答案 0 :(得分:1)

问题已解决 忘了重装主管:

supervisorctl reload

答案 1 :(得分:0)

enter image description here

附加我的项目存储库,相同的结构拉入文件夹/ home / ubuntu /下的服务器。

我猜“supervisord.conf”中的“directory”参数可能是问题,但无论我改变或注释掉它都不起作用。