Created
November 9, 2012 04:42
-
-
Save trobrock/4043720 to your computer and use it in GitHub Desktop.
System calls with goliath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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