How to run Celery and Django web app simultaneously on Railway?

27 Views Asked by At

I'm trying to deploy a Django web application along with Celery for background task processing on Railway. I've configured my railway.json deployment file as follows:

{
  "$schema": "https://railway.app/railway.schema.json",
  "build": {
    "builder": "NIXPACKS"
  },
  "deploy": {
    "startCommand": "celery -A core worker --loglevel=INFO && python manage.py migrate && python manage.py collectstatic --noinput && gunicorn core.wsgi --timeout 60",
    "numReplicas": null,
    "healthcheckPath": null,
    "healthcheckTimeout": null,
    "restartPolicyType": "ON_FAILURE",
    "restartPolicyMaxRetries": 10,
    "cronSchedule": null
  }
}

However, with this configuration, only Celery starts, and the Django web server (gunicorn) doesn't seem to run. How can I adjust my deployment configuration to ensure that both Celery and the Django web app start and run simultaneously?

I've tried rearranging the startCommand, placing celery at the end, but it doesn't seem to work. Any guidance or best practices for configuring Celery and Django web app deployments on Railway would be greatly appreciated.

0

There are 0 best solutions below