On 16/06/16 07:34 AM, Jani Tiainen wrote:
But there is no easy way to push arbitrary data through TCP socket to Django server directly - Django is mainly build around HTTP request - response cycle.

That is no longer true. Django Channels <https://github.com/andrewgodwin/channels> makes this dead easy.

We're using Django Channels in a control panel for Debian virtual machines. The user provides some basic configuration options for the AngularJS/Node.js application running within the VM, such as database auth info, networking info, etc. On save of the singleton MachineConfig object, we also save the same key/value pairs into a YAML file. There is a daemon that is running inotifywait monitoring that YAML file for changes and when it detects a change, it kicks off "salt-call --local ..." to have SaltStack configure the VM as per the key/value pairs in the YAML file. As Salt progresses through the various states, it sends a progress message on a WebSocket. Django is listening for those messages and displays them in an overlay that masks the page content below it on the control panel to provide an indication to the user what is happening inside the VM. When Salt has run through all the states and configured the VM, it sends a "Finished Configuring Machine" which is displayed for a few seconds and then hidden. The user then has access to the control panel again in case they want to change something later or restart the VM.

You can read more about Django Channels in a blog post <https://blog.heroku.com/archives/2016/3/17/in_deep_with_django_channels_the_future_of_real_time_apps_in_django> by Jacob Kaplan-Moss. My understanding is that Channels will be integrated in Django core at some point.

--
Regards,

Clifford Ilkay

+ 1 647-778-8696

--
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/73ff8744-4ea1-67f0-6bda-08d025526c03%40dinamis.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to