ixc / ixc-project-template

Bare-bones skeleton project template, for use with the `django-admin.py startproject` command.
1 stars 0 forks source link

`django-supervisor` sometimes chooses a conflicting "random-ish" port #16

Open mrmachine opened 9 years ago

mrmachine commented 9 years ago

https://github.com/rfk/django-supervisor - "automatic control socket config"

We should investigate how "random-ish" it is, how "fixed" it is, and why it is occasionally conflicting. Maybe we can make it more random, or more deterministic.

Alternatively, when this conflict occurs, you can work-around the issue by specifying a port number in supervisor.conf:

[inet_http_server]
port = *:61704 # if the gunicorn port is 51704, add 10,000 to make it 61704

Perhaps we can automatically extract the port number from the SUPERVISOR['ADDRESS'] setting and add 10,000 to it (as a default) and use that as the supervisor port number?

But a unix socket might be better, if we can put it in the project directory so we don't have to worry about port numbers:

[unix_http_server]
file = {{ settings.BASE_DIR }}/supervisor.sock # or /tmp/supervisor.{{ settings.PROJECT_NAME }}.sock

Unfortunately, the socket server only seems to work when run as root which negates a lot of the benefit that django-supervisor provides.

mrmachine commented 9 years ago

@sjdines

Actually, looks like the problem we were having was not that the port number wasn't random enough. It wasn't conflicting with another app. It was just that there was already another supervisor process running for the same app.

So when we tried to start it either via system level supervisor OR manually, it was unable to access the port. I think we just needed to do ./manage.py supervisor shutdown to kill the existing process, then we could restart it from command line or from system level supervisor.