Starting Celery on Production

Good day, I am trying to integrate celery and redis into a Django project that performs background tasks. The project works fine on the development server, I have tried to use the railway cli to start the celery worker and beat, but the process does work correctly. That is once I close the cli the celery worker and beat stops working. How can I achieve this.
Solution:
you want two railway services in the same railway project. one railway service will be for just for django the other railway service will be just for celery the two railway services will have all the same service variables the two railway services will deploy from the same github repository...
Jump to solution
17 Replies
Percy
Percy9mo ago
Project ID: 43cdf491-3552-4768-a29e-590c8f31e84c
Godisgreat
Godisgreat9mo ago
If project ID is the same as service ID then 43cdf491-3552-4768-a29e-590c8f31e84c Project ID: 43cdf491-3552-4768-a29e-590c8f31e84c
Adam
Adam9mo ago
the cli runs commands locally using the env vars on Railway, it does not run the command on Railways servers ssh access is not possible on Railway, you’ll have to find another way to start your workers
Brody
Brody9mo ago
you create another empty railway service in your pre existing project, set the appropriate start command for celery in the service settings, set up all the needed service variables, and then attach your github repo in the service settings, it will then deploy and start celery
Godisgreat
Godisgreat9mo ago
Please explain more on how to do this. Please explain more on how to do this.
Brody
Brody9mo ago
that is the explanation
Godisgreat
Godisgreat9mo ago
@Godisgreat thanks I have been able to make progress. How Can I have more than one start command
Brody
Brody9mo ago
set the appropriate start command for celery in the service settings
Godisgreat
Godisgreat9mo ago
The second service you talk about how should I do it
Brody
Brody9mo ago
in the service settings, like i have already mentioned
Godisgreat
Godisgreat9mo ago
@Brody Please I am having a hard time doing this I will send some pictures of what my setup looks like
Godisgreat
Godisgreat9mo ago
No description
Solution
Brody
Brody9mo ago
you want two railway services in the same railway project. one railway service will be for just for django the other railway service will be just for celery the two railway services will have all the same service variables the two railway services will deploy from the same github repository the django railway service will have a start command set to start only django the celery railway service will have a start command set to start only celery the start command input field can be found in the service settings of the railway service
Brody
Brody9mo ago
im sorry but i dont know how i could explain this better unless i took control of your computer and did it for you
Godisgreat
Godisgreat9mo ago
@Brody if I get what you are saying I will deploy my project twice and set the celery worker command on one right?
Brody
Brody9mo ago
please no pings #🛂|readme #5 as previously mentioned you need two railway services in your current railway project, if you don't know how to add a service there is a + New button in the top right of the project view
Godisgreat
Godisgreat9mo ago
Okay thanks Sovled