Gunicorn - Where do Unix sockets come from?

I am trying to configure Gunicorn to use a Unix socket, but I can not find any documentation on how these sockets are created or how to fix them.

I am setting up a Django application and I can successfully run on http by specifying a port. However, when I try to use a Unix socket:

gunicorn myapp.wsgi:application --bind=unix:/appuser/myapp/gunicorn.sock

He returns with:

[2015-11-21 09:34:21 +0000] [24380] [INFO] Starting gunicorn 19.3.0
[2015-11-21 09:34:21 +0000] [24380] [ERROR] Retrying in 1 second.
[2015-11-21 09:34:22 +0000] [24380] [ERROR] Retrying in 1 second.
[2015-11-21 09:34:23 +0000] [24380] [ERROR] Retrying in 1 second.
[2015-11-21 09:34:24 +0000] [24380] [ERROR] Retrying in 1 second.
[2015-11-21 09:34:25 +0000] [24380] [ERROR] Retrying in 1 second.
[2015-11-21 09:34:26 +0000] [24380] [ERROR] Can't connect to /appuser/myapp/gunicorn.sock

Gunicorn.sock is located right where it should be, but the file is empty. I can not find a single magazine. I am using Nginx on an AWS server and have configured all the relevant configurations as per the docs . I can post my configuration if it has anything to do with this.

How to fix this problem?

+4
1

UNIX. , cat.

UNIX , , . , , . ; . , , ( ), - ( ) .

:

>>> import socket
>>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
>>> s.bind("foo.sock")
# now foo.sock exists
>>> s.close()
# foo.sock still exists
>>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
>>> s.bind("foo.sock")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 98] Address already in use
# boom, the socket must be unlinked manually
>>> import os
>>> os.unlink("foo.sock")
>>> s.bind("foo.sock")
>>> s.close()

, nginx - http 127.0.0.1:someport.

+4

Source: https://habr.com/ru/post/1616844/


All Articles