1

I'm trying to figure out what the best way to actually invoke one of these on my pod. ie: For Django-Background-Tasks, you need to run python manage.py process_tasks

How do I run this on my Django pod automatically, without having to ssh into my pod and just run it. I've been trying to use a Post Lifecycle Hook, but maybe I'm just doing it wrong.

Any help would be appreciated.

Thanks!

P.S I'm currently working on a basic example using the openshift 3 django-ex github repo. (https://github.com/sclorg/django-ex)

tw0shoes
  • 167
  • 2
  • 8
  • 1
    Change the Dockerfile or deployment config to start that command. Without any details I can't give detailed advise. – Klaus D. Feb 28 '18 at 04:05
  • Hey! Thanks for the response. I'm working through the gui. What kind of details do you need? – tw0shoes Feb 28 '18 at 04:06
  • 1
    @KlausD. You can't change the start command for the image. That would be what is running the Django instance. – Graham Dumpleton Feb 28 '18 at 06:27
  • 2
    @JamesSoper In your use case, does ``python manage.py process_tasks`` need to be run only once and it will then stay running forever, or is it a one off thing that you need to run periodically. In the first scenario, is it possible that it still could exit for some reason and needs to be restarted automatically. In a container you have no cron system to run stuff periodically. There are potentially ways around that, but need to know better the requirements. – Graham Dumpleton Feb 28 '18 at 06:33
  • Run once and stay running forever would be great. I'll be running tasks every day, on a regular basis. If it could be restarted automatically upon failure that would be great as well. I've figured out how to run some cron stuff, but it's pretty limited. Anything else you need from me? – tw0shoes Mar 02 '18 at 08:06
  • @GrahamDumpleton, sorry to bug you, but I'm really interested in your answer haha. I've tried looking through heaps of documentation on this and can't seem to figure it out. – tw0shoes Mar 06 '18 at 20:42
  • 1
    If you are using mod_wsgi-express to host Django then I can help you with a solution. – Graham Dumpleton Mar 06 '18 at 23:49
  • @GrahamDumpleton To be honest, I'm not quite sure, but I don't think so. I just started modifying their example project (https://github.com/sclorg/django-ex) and since I've never had an issue with it, i've never looked into it. From what I've looked up (on your site no less), it looks like you need mod_wsgi.server installed as an application to be using it, so no. Honestly at this point I don't even know what to read up on further, so any help at all with where to go next to try to get some answers, i'm new to the whole gunicorn/wsgi running it on a server world. – tw0shoes Mar 09 '18 at 20:40
  • If interested at all in swapping to mod_wsgi-express, suggest taking the discussion to the mod_wsgi mailing list. – Graham Dumpleton Mar 09 '18 at 20:56
  • How difficult is it once you've switched? I feel like so far these comments aren't really useful to anyone else finding this thread. – tw0shoes Mar 09 '18 at 23:53
  • @GrahamDumpleton, so I found this answer for people who are using mod_wsgi-express: https://stackoverflow.com/questions/48102638/how-to-run-celery-with-django-on-openshift-3 Which is actually you answering it. I've also been looking at a bunch of stuff on cron jobs w/in the same pod. Like this, which is again you answering it: https://stackoverflow.com/questions/45227768/do-openshift-origin-jobs-need-hard-coded-internal-registry-urls-for-images/45227960#45227960 I haven't quite found what I'm looking for, which is something that works with my current set up, but I'll continue to look. – tw0shoes Mar 27 '18 at 03:07
  • I did suggest you take the discussion to the mod_wsgi mailing list so can discuss it properly if happy to use mod_wsgi-express. The mod_wsgi list is at https://groups.google.com/forum/#!forum/modwsgi. Doing it here on StackOverflow isn't the best place. That or use the OpenShift mailing list at https://groups.google.com/forum/#!forum/openshift. – Graham Dumpleton Mar 27 '18 at 07:01
  • Another example using mod_wsgi-express is https://github.com/openshift-katacoda/blog-django-py/blob/master/app.sh#L29 and https://github.com/openshift-katacoda/blog-django-py/blob/master/cronjobs.py – Graham Dumpleton Mar 27 '18 at 07:02

0 Answers0