Sha256: 7aabd7e52b7cd923cfdfd73cf9ba755da9384dec482e804982864389c61f3977
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
require 'webrick' require 'rio' class TempServer def initialize(server_config = {}) @logdir = rio('log').delete!.mkdir @config = { :DocumentRoot => rio('srv/www/htdocs').abs, :Logger => WEBrick::Log.new(@logdir/'server.log'), :AccessLog => [[ @logdir/'access.log', WEBrick::AccessLog::COMBINED_LOG_FORMAT ]], :Port => ENV['RIO_TEST_PORT'] || '8088', } @config.merge!(server_config) ENV['RIO_TEST_PORT'] = @config[:Port] @server = create_server(@config) end def self.run(*args) new.run(*args) end def create_server(config = {}) server = WEBrick::HTTPServer.new(config) yield server if block_given? ['INT', 'TERM'].each {|signal| trap(signal) {server.shutdown} } server end def run_progs(progs) progs.each do |prog| system("ruby #{prog}") end end def run(*programs) Thread.new(@server) { |srv| srv.start } Thread.new(programs) { |progs| #Thread.pass run_progs(progs) }.join() Thread.new(@server) { |srv| srv.shutdown } end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
wishdev-rio-0.4.3.1 | test/lib/temp_server.rb |
rio-0.4.1 | test/lib/temp_server.rb |
rio-0.4.2 | test/lib/temp_server.rb |