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

39 messages · Page 1 of 1 (latest)

pure raft
#

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!

remote pikeBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

wind lichenBOT
#

Project ID: df711288-dddd-4e3e-8f3f-62aefe4a3212

pure raft
#

df711288-dddd-4e3e-8f3f-62aefe4a3212

plain pollen
#

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

pure raft
timid rain
#

Did you set up the Redis server yet in your project?

pure raft
#

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'),
}

timid rain
#

You're gonna need more than just the URL

#

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

plain pollen
#

so nothing wrong with using the URL as it contains everything the other environment variables do

#

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

#

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

plain pollen
#

@pure raft 🙂

pure raft
plain pollen
#

no prob 🙂

pure raft
plain pollen
#

same github repo and branch for both services, these two services will be near exact clones, the only difference being their start commands

pure raft
#

I'm deploying through Github, so am not sure exactly how to export different versions of the Procfile to both services.

plain pollen
#

as previously mentioned you will use the start command field In the service settings, with that you can effectively delete the procfile

pure raft
#

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

plain pollen
#

why?

pure raft
#

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

plain pollen
#

oh haha yeah definitely don't do two branches

pure raft
#

alrighty