mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
improve integration server handling
This commit is contained in:
parent
895b09b207
commit
a2c67e4e27
1 changed files with 8 additions and 2 deletions
|
@ -36,6 +36,7 @@ module IntegrationHelper
|
|||
|
||||
def run
|
||||
return unless installed?
|
||||
kill
|
||||
@log = ""
|
||||
@pipe = IO.popen(command)
|
||||
@started = Time.now
|
||||
|
@ -64,7 +65,7 @@ module IntegrationHelper
|
|||
def alive?
|
||||
3.times { get('/ping') }
|
||||
true
|
||||
rescue Errno::ECONNREFUSED, Errno::ECONNRESET => error
|
||||
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError => error
|
||||
false
|
||||
end
|
||||
|
||||
|
@ -127,7 +128,12 @@ module IntegrationHelper
|
|||
super "with #{server.name}: #{message}" do
|
||||
self.server = server
|
||||
server.run unless server.alive?
|
||||
begin
|
||||
instance_eval(&block)
|
||||
rescue Exception => error
|
||||
server.kill
|
||||
raise error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue