How to run an external command that must run with the server

60 views
Skip to first unread message

Alex

unread,
Apr 1, 2018, 7:06:23 AM4/1/18
to Django users
I have a daphne server running a django channels application. I also have a python script that aggregates data from various sources, and sticks it into the channel layer (called source.py). At the moment, I run it as a management command (python manage.py source). It is nearly time for deployment(!), so I'm moving towards production solutions. Daphne itself currently runs under supervisor.

My question is, what is the best way to run source.py? As a management command, also under supervisor? Using celery? In some other way? Since source.py feeds into the channel layer, it needs access to settings.py in order to identify the details of the channel layer etc.

Ken Whitesell

unread,
Apr 1, 2018, 8:16:38 AM4/1/18
to django...@googlegroups.com
We set up all our Django-related processes as a group under supervisor. This includes our celery-based processes. (We have some long-running tasks that are kicked off by the web site.) By setting it up as a group, we can manage all the different processes as a set.

Whether or not that's the "best" way is possibly debatable. But it works for us and doesn't give us any problems.

Ken


On 4/1/2018 7:06 AM, 'Alex' via Django users wrote:
I have a daphne server running a django channels application. I also have a python script that aggregates data from various sources, and sticks it into the channel layer (called source.py). At the moment, I run it as a management command (python manage.py source). It is nearly time for deployment(!), so I'm moving towards production solutions. Daphne itself currently runs under supervisor.

My question is, what is the best way to run source.py? As a management command, also under supervisor? Using celery? In some other way? Since source.py feeds into the channel layer, it needs access to settings.py in order to identify the details of the channel layer etc.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b3c22939-b520-4c9c-90f9-ef8cb7b8c661%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Alex

unread,
Apr 3, 2018, 6:15:07 AM4/3/18
to Django users
That makes sense. So leave the source as a management command (as it is now), and just run python manage.py source through supervisor?

Ken Whitesell

unread,
Apr 3, 2018, 9:09:40 AM4/3/18
to django...@googlegroups.com

There's an aspect of your situation which isn't entirely clear to me - is this management command one that remains running all the time, like a Celery task would be; or is it one that starts, runs a process for a period of time, and then ends - only to be restarted at a later time? If the former, then yes, running the management command from supervisor makes sense to me. If the latter, then I'd probably be looking at doing something different.


Ken


Alex

unread,
Apr 3, 2018, 9:52:20 AM4/3/18
to Django users
Yes, it runs constantly, whenever the server is up. Ok, I'll stick with the management command as a supervisor process, thank you!
Reply all
Reply to author
Forward
0 new messages