Skip to content

Instantly share code, notes, and snippets.

@leucos
Created August 20, 2013 07:51
Show Gist options
  • Select an option

  • Save leucos/6278332 to your computer and use it in GitHub Desktop.

Select an option

Save leucos/6278332 to your computer and use it in GitHub Desktop.
EventMachine + popen
#!/bin/bash
for i in {1..1000}; do
echo -n $i
sleep 0.001
done
#!/usr/bin/env ruby
require 'eventmachine'
def log *message
p [Time.now, *message]
end
module EventMachine
class LiveProcess < EM::Connection
def initialize *args
@buffer = ""
log __method__, args
end
def receive_data data
log __method__, data
@buffer << data
end
def unbind
log __method__
end
end
end
EM.run {
EM.popen "./tailer.sh", EM::LiveProcess
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment