R
Railway5mo ago
zbellay

Can't Override Custom Start Command

Hello! I am trying to deploy a django + celery monorepo. I would like to have one service running the web service, and another running a workser. I am using a railway.json as follows:
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
This is great for the web service, but when I go to the worker service, it shows that I cannot override the start command (see attached). Would appreciate any suggestions/help here. Thanks! Project ID: ac5816c7-c5de-43a5-84b7-b78cc622b173
No description
7 Replies
Percy
Percy5mo ago
Project ID: ac5816c7-c5de-43a5-84b7-b78cc622b173
Adam
Adam5mo ago
Sounds to me like your repo is formatted odd. Are your web and worker services in the same repo? And do you mean frontend and backend when you say web and worker? if not, please explain what you mean
zbellay
zbellay5mo ago
Yes, they are in the same repo. My web service is just my django server, which just serves HTML. My worker service runs various tasks. This is a common pattern in django. E.g. on Heroku w/ Procfiles you might have:
web: gunicorn mysite.conf
worker: celery -A mysite -l INFO
web: gunicorn mysite.conf
worker: celery -A mysite -l INFO
Adam
Adam5mo ago
Right, I figured that’s what you meant. You can’t separate workers into a separate service from the web. Services on Railway each have their own container, so they can’t communicate directly as a web and worker need to do What it sounds like you want to do is have a frontend and backend so the worker’s processing doesn’t interfere with the web service’s regular operation. if you want more workers, just increase the number in the start command. If you want more separation between your frontend and backend, you’ll have to create a backend api
zbellay
zbellay5mo ago
So I just found this repo, which uses django + celery on railway, it doesn't use the railway.json, so maybe I need to change how I'm deploying https://github.com/Antvirf/railway_django_stack But still, in these Railway docs it says you can deploy from a monorepo using start command overrides: https://docs.railway.app/guides/monorepo#deploying-a-shared-monorepo I don't see why my case would be any different, but I am prevented from doing so
Adam
Adam5mo ago
railway.json files set Railway settings and don’t allow you to change them, which is why you can’t do so I also don’t believe that the repo you sent is a monorepo per se The workers and web are in the same service the database is separate, but that doesn’t really constitute a monorepo
zbellay
zbellay5mo ago
I see, so it sounds like I'd need to move from a railway.json to Dockerfiles I'm gunna give this template a shot: https://github.com/Antvirf/railway_django_stack I don't fully understand why the railway.json can't just allow for configurable start commands, but that's ok Thank you for your help Adam
GitHub
GitHub - Antvirf/railway_django_stack: A Railway template for a ful...
A Railway template for a full Django app with a Celery worker, Redis and PostgreSQL - GitHub - Antvirf/railway_django_stack: A Railway template for a full Django app with a Celery worker, Redis and...