public
Last active

Preloading dependencies

  • Download Gist
client.rb
Ruby
1 2 3 4
require 'drb'
 
runner = DRbObject.new nil, 'druby://:4321'
runner.run(ARGV)
server.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
require 'drb'
ARGV.each { |file| require File.expand_path file }
Rails.env = 'test' if defined? Rails
 
class Runner
def run(files)
fork do
files.each { |file| require File.expand_path file }
end
Process.wait
end
end
 
DRb.start_service 'druby://:4321', Runner.new
DRb.thread.join
slow.rb
Ruby
1
sleep 2
test.rb
Ruby
1 2 3 4 5 6
require File.expand_path 'slow'
 
100.times do
sleep rand * 0.01
print '.'
end
threetimes.rb
Ruby
1 2 3 4 5 6 7 8 9
require File.expand_path 'slow'
 
3.times do
fork do
require File.expand_path 'test'
end
 
Process.wait
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.