Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNIX domain socket raises 503 when workers are used #428

Closed
ivankravets opened this issue Sep 18, 2019 · 1 comment · Fixed by #1009
Closed

UNIX domain socket raises 503 when workers are used #428

ivankravets opened this issue Sep 18, 2019 · 1 comment · Fixed by #1009

Comments

@ivankravets
Copy link

Is it Ok when a combination of --workers and --uds raises 503 error via nginx? For example:

--workers 4 --uds /var/run/uvicorn-test.sock

it works well when --workers is omitted (1 worker). Please note that gunicorn works well via Unix socket and multiple workers.

Thanks!

@Hanaasagi
Copy link
Contributor

It seems that when combine the --workers and --uds arguments. uvicorn will ignore --uds and create a tcp socket.

uvicorn/uvicorn/main.py

Lines 274 to 277 in e0a77de

elif config.workers > 1:
sock = config.bind_socket()
supervisor = Multiprocess(config)
supervisor.run(server.run, sockets=[sock])

uvicorn/uvicorn/config.py

Lines 220 to 228 in e0a77de

def bind_socket(self):
sock = socket.socket()
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((self.host, self.port))
sock.set_inheritable(True)
message = "Uvicorn running on %s://%s:%d (Press CTRL+C to quit)"
protocol_name = "https" if self.is_ssl else "http"
self.logger_instance.info(message % (protocol_name, self.host, self.port))
return sock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants