2015-08-23 11 views
7

Sto usando Django 1.8 e voglio eseguire la mia applicazione con gunicorn.gunicorn: Impossibile connettersi a gunicorn.sock

posso eseguirlo OK dalla riga di comando vincolante alla mia IP:

gunicorn myapp.wsgi:application --bind xx.xx.xx.xx:8001 

Ma ora voglio farlo funzionare tramite un socket Unix:

gunicorn myapp.wsgi:application --bind=unix$/webapps/myapp/run/gunicorn.sock 

ottengo questo errore:

[2015-08-23 07:38:04 +0000] [18598] [INFO] Starting gunicorn 19.3.0 
[2015-08-23 07:38:04 +0000] [18598] [ERROR] Retrying in 1 second. 
[2015-08-23 07:38:05 +0000] [18598] [ERROR] Retrying in 1 second. 
[2015-08-23 07:38:06 +0000] [18598] [ERROR] Retrying in 1 second. 
[2015-08-23 07:38:07 +0000] [18598] [ERROR] Retrying in 1 second. 
[2015-08-23 07:38:08 +0000] [18598] [ERROR] Retrying in 1 second. 
[2015-08-23 07:38:09 +0000] [18598] [ERROR] Can't connect to $/webapps/myapp/run/gunicorn.sock 

Se faccio ls -al /webapps/myapp/run vedo che il file di socket esiste, anche se è vuota:

srwxrwxrwx 1 opuser webapps 0 Aug 23 07:22 /webapps/myapp/run/gunicorn.sock 

Come posso risolvere questo problema?

Alla fine voglio eseguire gunicorn come utente opuser, ho provato ad aggiungere --user opuser --group webapps al comando gunicorn, ma ho ancora lo stesso errore.

+2

Sei sicuro che la sintassi sia 'unix $ PATH', non' unix: PATH'? [I documenti sembrano suggerire quest'ultimo.] (Https://gunicorn-docs.readthedocs.org/en/latest/settings.html#bind) –

risposta

5

Secondo la documentazione (http://gunicorn-docs.readthedocs.org/en/latest/run.html), si dovrebbe usare: unix:$(PATH), che significa il comando dovrebbe leggere:

gunicorn myapp.wsgi:application --bind=unix:/webapps/myapp/run/gunicorn.sock 
+0

Modificato - ora ho l'errore 'OSError: [Errno 13] Autorizzazione negato: '/ webapps/openprescribing/run/gunicorn.sock' che immagino sia un progresso! Qualche idea su come posso risolvere il problema? Sembra strano dato che 'opuser' è il proprietario del file' gunicorn.sock'. – Richard

+0

Suppongo che non stia eseguendo il comando 'gunicorn' come' opuser', sebbene ...? Devo dare l'autorizzazione dell'utente corrente per connettersi anche a 'gunicorn.sock'? – Richard

+0

Solo per la risoluzione dei problemi è possibile concedere i diritti 777 al socket e vedere cosa succede. – henrikstroem

-1

Basta usare seguente comando senza virgolette: "gunicorn appname.wsgi". Assicurati di eseguire questo comando dove si trova wsgi.py.

Problemi correlati