R
Railwayβ€’14mo ago
ValeriuV

How do I deploy Django-Q (task queue) to Railway?

Are there any tutorials on how to achieve this? After searching for a bit it looks like I need to do the following: 1. Redis DB service and connect to it from settings.py under the Q_CLUSTER/redis settings 2. set the worker in the Procfile: worker: python manage.py qcluster I did both those things but still the tasks don't start. Thanks!
Solution:
so like mentioned previously, you want two railway services, these two railway services should be near exact clones of each other, same environment variables, deploy from the same github repo, in the same project, the only difference being that you'd change the start command in the service settings of one to run the django stuff, and in the other service you'd set the start command to only run the task queue
Jump to solution
21 Replies
Percy
Percyβ€’14mo ago
Project ID: df711288-dddd-4e3e-8f3f-62aefe4a3212
ValeriuV
ValeriuVOPβ€’14mo ago
df711288-dddd-4e3e-8f3f-62aefe4a3212
Brody
Brodyβ€’14mo ago
you want a two railway services, one service runs the task queue, the other service runs django don't try to run the task queue and django in a single service
ValeriuV
ValeriuVOPβ€’14mo ago
Brody, thank you for the tip. But how do I set that up? Right now I have one Procfile that has this one line in it: web: python manage.py migrate && python manage.py collectstatic --no-input && gunicorn fleetdata.wsgi & python manage.py qcluster
Iceman
Icemanβ€’14mo ago
Did you set up the Redis server yet in your project?
ValeriuV
ValeriuVOPβ€’14mo ago
yes. Q_CLUSTER = { 'name': 'fleetdata', 'workers': 8, 'recycle': 500, 'timeout': 6000, 'retry': 10000, 'compress': True, 'save_limit': 250, 'queue_limit': 500, 'cpu_affinity': 1, 'label': 'Django Q', 'redis': config('REDIS_URL'), }
Iceman
Icemanβ€’14mo ago
You're gonna need more than just the URL Looks like you need a dictionary based on this: https://django-q.readthedocs.io/en/latest/configure.html Try changing it to something like this: 'redis' : { host=env('REDISHOST'), port=env('REDISPORT'), password=env('REDISPASSWORD') } or whatever you're using for your environment variables
Brody
Brodyβ€’14mo ago
from the docs you linked
It’s also possible to use a Redis connection URI
so nothing wrong with using the URL as it contains everything the other environment variables do
Solution
Brody
Brodyβ€’14mo ago
so like mentioned previously, you want two railway services, these two railway services should be near exact clones of each other, same environment variables, deploy from the same github repo, in the same project, the only difference being that you'd change the start command in the service settings of one to run the django stuff, and in the other service you'd set the start command to only run the task queue
Brody
Brodyβ€’14mo ago
django service start command: python manage.py migrate && python manage.py collectstatic --no-input && gunicorn fleetdata.wsgi task queue service start command: python manage.py qcluster I hope this explains it well enough, but let me know if I need to clarify something @ValeriuV πŸ™‚
ValeriuV
ValeriuVOPβ€’14mo ago
@Brody , alright, I'll try that tonight and get back to you. Thank you!
Brody
Brodyβ€’14mo ago
no prob πŸ™‚
ValeriuV
ValeriuVOPβ€’14mo ago
The next question that pops to my mind is how do I do that? Should I use a different github branch?
Brody
Brodyβ€’14mo ago
same github repo and branch for both services, these two services will be near exact clones, the only difference being their start commands
ValeriuV
ValeriuVOPβ€’14mo ago
I'm deploying through Github, so am not sure exactly how to export different versions of the Procfile to both services.
Brody
Brodyβ€’14mo ago
as previously mentioned you will use the start command field In the service settings, with that you can effectively delete the procfile
ValeriuV
ValeriuVOPβ€’14mo ago
oh, got it. trying now wooooooooaaaaaaaaaaaaa it worked I'm so thankful Brody you are the man! I would have never figured it out that I should have another service for task queues but I did it through two git branches
Brody
Brodyβ€’14mo ago
why?
ValeriuV
ValeriuVOPβ€’14mo ago
one for main and another for django-q that's what I assumed before you wrote your detailed explanation I guess I should do it with the start command ok, working on it
Brody
Brodyβ€’14mo ago
oh haha yeah definitely don't do two branches
ValeriuV
ValeriuVOPβ€’14mo ago
alrighty
Want results from more Discord servers?
Add your server