Skip to content

Instantly share code, notes, and snippets.

@tomlea
Created January 6, 2009 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomlea/43835 to your computer and use it in GitHub Desktop.
Save tomlea/43835 to your computer and use it in GitHub Desktop.
require 'drb'
module RemoteRunner
module Runner
def eval(code)
Kernel.eval(code)
end
end
def load_app(app)
Dir.chdir(File.join(File.dirname(__FILE__), "..", app))
ENV["RAILS_ENV"] ||= "integration"
require "config/boot"
DRb.start_service nil, Runner
puts DRb.uri
DRb.thread.join
end
def with_app(app)
pipe = IO.popen("ruby #{__FILE__} #{app}")
url = pipe.gets
pid = pipe.pid
yield DRbObject.new(nil, url)
ensure
Process.kill("TERM", pid)
Process.waitpid(pid)
end
extend self
end
if File.expand_path($0) == __FILE__
RemoteRunner.load_app(ARGV.last || raise("This script is not designed to be run directly."))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment