18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/feedcellar/test/server.rb', line 18
def start
config = {
:DocumentRoot => './',
:BindAddress => '127.0.0.1',
:Port => PORT,
}
srv_proc = lambda do
Dir.chdir(@tmpdir) do
srv = WEBrick::HTTPServer.new(config)
trap("INT") { srv.shutdown }
srv.start
end
end
if File.basename($0) == "feedcellar-test"
srv_proc.call
else
if @server && @server.alive?
$stderr.puts("Server is still running.")
return false
end
config[:Logger] = WEBrick::Log.new(File.open(File::NULL, "w"))
config[:AccessLog] = []
@server = Thread.start(&srv_proc)
end
end
|