DEV Community


Posted on

Stream cli output over http


A program to stream any command line output over http. This is useful when we want to display command output on client side. One such use case can be displaying live logs in browser which are running inside a container on server side.


  • Using docker (recommended)
  git clone
  cd runnel

  # build docker image
  docker build -t runnel:latest .

  # start runnel server
  docker run --name runnel -d -p runnel:latest
Enter fullscreen mode Exit fullscreen mode
  • Using binary (not recommended, because system dependencies are taken care in docker file on behalf of you)
  git clone
  cd runnel

  ./bin/linux_64/runnel_server -p localhost:9090
Enter fullscreen mode Exit fullscreen mode


  • Trigger below commands to get live stream
  # Fire command with curl
  curl -X POST -H 'Content-Type: application/json' -d '{"cmd":"ping -c 3"}' http://localhost:9090/command

  # Get live output stream
  # replace uuid with one which you get from above command
  while true; do curl -sS -H 'Content-Type: application/json' 'http://localhost:9090/stream/fd4b1a38-94f4-4eba-80e7-50578ac4baae' | jq '.response'; done
Enter fullscreen mode Exit fullscreen mode


  • Dependency: Install redis server
  • Use as golang package
  # Get lib
  go get

  # Fire command
  client := runnel.NewClient()
  key, err := client.RunCommand("ping", "-c 2")

  # Get output stream
  client := runnel.NewClient()
  output, err := client.Stream(key, 10)
Enter fullscreen mode Exit fullscreen mode

Detailed documentation:

Top comments (0)