Skip to content

Instantly share code, notes, and snippets.

@trobrock
Created November 9, 2012 04:42
Show Gist options
  • Save trobrock/4043720 to your computer and use it in GitHub Desktop.
Save trobrock/4043720 to your computer and use it in GitHub Desktop.
System calls with goliath
require 'goliath'
module EventMachine
module Synchrony
# Fiber-aware EM.system
#
def self.system cmd, *args
fiber = Fiber.current
EM.system(cmd, *args){ |out, status| fiber.resume( [out, status] ) }
Fiber.yield
end
end
end
class Deploy < Goliath::API
def response(env)
puts "Processing request"
output, status = EM::Synchrony.system "sh", "-c", "sleep 10 ; echo 'hello world'"
puts output
[200, {}, output]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment