✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Dash not working with Gunicorn+SupervisorCTL

There’s a weird issue with Dash using Gunicorn+SupervisorCTL

I’m runing a hybrid Flask+FlaskRestful with Gunicorn and SupervisorCTL and I just added Dash to it.

My structure is:

main.py (where Flask is created, passed to Flask Restful, SqlAlchemy and now Dash)
index.py (where dash loads its layout - the entry point - imports app from main.py)

In index.py I have the following:

from main import app

# ...
app.layout = layout
# ...
# ...
server = app.server
if __name__ == '__main__':

Now, when I get into venv with the correct user and I do gunicorn index:server, it works perfectly.

But when I use supervisorctl to do it, it doesn’t work!

Here’s how it looks in supervisor:
command = /opt/myapp/run.sh gunicorn -c /etc/gunicorn.conf.py index:server

Where run.sh starts the .venv

I tried doing index:app.server but everytime I get:

Application object must be callable.

While this does not happen when I call the command directly.