Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running manage.py worker in a Cpanel shared env #52

Open
collinr3 opened this issue May 21, 2022 · 5 comments
Open

Running manage.py worker in a Cpanel shared env #52

collinr3 opened this issue May 21, 2022 · 5 comments

Comments

@collinr3
Copy link
Contributor

collinr3 commented May 21, 2022

Hi,

Firstly, thank you for sharing this app - I heard Jamie mention it on DjangoChat a while back.

I'm now looking to use it and I wonder if you can help me.

I have my django app running in a shared env (Hostpresto) under Phusion passenger and I want to add 'django-db-queue' to manage periodic tasks. The hosting team suggest setting up a cron job to to run. manage.py worker periodically.

Q1: Do you have any experience of deploying this app into a cpanel /shared env, if so how did you make it work?

Q2: In your opinion, is using cron to run manage.py worker a reasonable approach.

Thoughts?

Rob

@collinr3 collinr3 changed the title Running manage.py worker n a Running manage.py worker in a Cpanel shared env May 21, 2022
@RealOrangeOne
Copy link
Contributor

Cron and manage.py worker aren't really compatible models. The worker command will never exit, as it waits for command to run.

Cpanel hosting of this is probably out of scope for an issue here, but if there's a way to run some form of background process, that's the way.

Alternatively, perhaps a manage.py worker --oneshot variant which runs all available jobs and then exits could be useful?

@j4mie
Copy link
Member

j4mie commented May 23, 2022

Thanks for trying out django-db-queue!

As @RealOrangeOne says above, running the worker under cron doesn't really fit with django-db-queue's design, because cron is intended for finite tasks that do their work and then exit, whereas the worker is supposed to keep running in the background forever. You may be able to get this to work by doing something clever with pidfiles and a pile of bash, but it would probably be a bit unpredictable.

Note this issue is really a duplicate of #16

I would be happy to review a PR that adds this functionality, although I'm not completely decided that it's a good thing to do, as it's not something that we would need so would be a maintenance burden. It would depend on how big the diff ends up being!

@collinr3
Copy link
Contributor Author

Thanks both for your input, really helpful. I'm going to do a couple of experiments, which I will report back on in due course, for the record.

  1. A 'do nothing' option ie start the worker running 'as is' and give it a job to report daily 'alive a live o' - that will give me a feel for how long the worker will run for in my specific hosted env. This will likely take a small number of weeks to perform.

  2. Implement a '--cycles' (working title) concept that instructs the worker on how long their 'shift' is for. My thinking being is that this builds in a bit of future proofing for the user that wants more than 1 but less than infinity. I will strive for simple elegance to minimise any maintenance burden. If I think the change meets the maintenance requirement I will submit a PR for consideration.

@collinr3
Copy link
Contributor Author

Hi, Pull request #55 is now available for your consideration

@collinr3
Copy link
Contributor Author

collinr3 commented Sep 7, 2022

Also addresses #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants