Custom start command for Django + GUnicorn

afernandez
HOBBYOP

21 days ago

My app requires a custom start command.
the "collectstatic" is needed in prod to copy the contents from static to staticfiles.

Essentially, it needs to run:

python manage.py collectstatic --clear --no-input
python manage.py runserver
gunicorn my_project.wsgi:application

The issue is that runserver and gunicorn are both commands that need to run in the foreground; and I've already tried several combinations of trying to modify the start command, running in the background, etc.

1. Custom start command (doesn't like ";" to run multiple commands)

python manage.py collectstatic --clear --no-input && python manage.py runserver && gunicorn mu_project.wsgi:application
  1. Wrapping these in a shell script, e.g,.

    /bin/sh -c "/app/run_prod.sh"

  2. Running both the script and Gunicorn,

    /bin/sh -c "/app/run_prod.sh" && gunicorn stealth_ai.wsgi:application

$10 Bounty

2 Replies

Railway
BOT

21 days ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


Does the gunicorn process not complete? What's the actual issue you're having? The command you shared should run them in succession.


Loading...