0

Assuming I will use gunicorn to mount a django application:

  1. How can I bind to both localhost:8000 AND to a unix socket?
  2. How can I distinguish whether the request (in a view) is coming from the unix socket?

1 Answer 1

1

You could use something like Gunicorn to listen on both a UNIX socket and a TCP port.

In order to distinguish between the two in your views, I'd simply run two processes - One that listens on the TCP port and one for the UNIX socket. When starting said process, specify an environment variable which you can later access in your view.

Sign up to request clarification or add additional context in comments.

2 Comments

sounds good, and cleaner. I was planning to use gunicorn. how do I bind a unix socket with gunicorn?
See this link: docs.gunicorn.org/en/latest/run.html?highlight=unix - basically just pass unix:/path/to/socket instead of the regular host:port syntax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.