Search code examples
pythontwistedautobahncrossbarwamp-protocol

Pipe program stdout to a crossbar.io router


How can I send the stdout of a compilation process to a crossbar.io-Router?

I am working on a travis-like continuous-integration-system for compiling Github-hosted LaTeX documents/projects. The server receives a POST from Github and starts the compilation process. The compiler's output should then be displayed real-time in a virtual console on a website.

Is this possible with crossbar.io and autobahn|Python running on Debian?


Solution

  • Yes, possible. I estimate roughly 50 lines Python code + JS in browser (dump to JS console: 20 lines).

    Here is what you need to do when using AutobahnPython plus Python 2 and Twisted:

    1. Write a Twisted Web resource that receives the HTTP/POST
    2. Upon receiving the POST, start a child process (your compiler thing) using Twisted's process support
    3. Upon receiving stuff from stdout from the child process, publish WAMP events to Crossbar.io via ..
    4. .. a WAMP app component that you previously created and connected to Crossbar.io