Class: Webrat::Selenium::ApplicationServers::Sinatra

Inherits:
Base
  • Object
show all
Defined in:
lib/webrat/selenium/application_servers/sinatra.rb

Instance Method Summary collapse

Methods inherited from Base

#boot, #prepare_pid_file, #stop_at_exit, #wait, #wait_for_socket

Methods included from SilenceStream

#silence_stream

Instance Method Details

#failObject



23
24
25
26
27
28
# File 'lib/webrat/selenium/application_servers/sinatra.rb', line 23

def fail
  $stderr.puts
  $stderr.puts
  $stderr.puts "==> Failed to boot the Sinatra application server... exiting!"
  exit
end

#pid_fileObject



30
31
32
# File 'lib/webrat/selenium/application_servers/sinatra.rb', line 30

def pid_file
  prepare_pid_file(Dir.pwd, 'rack.pid')
end

#startObject



8
9
10
11
12
13
# File 'lib/webrat/selenium/application_servers/sinatra.rb', line 8

def start
  fork do
    File.open('rack.pid', 'w') { |fp| fp.write Process.pid }
    exec 'rackup', File.expand_path(Dir.pwd + '/config.ru'), '-p', Webrat.configuration.application_port.to_s
  end
end

#stopObject



15
16
17
18
19
20
21
# File 'lib/webrat/selenium/application_servers/sinatra.rb', line 15

def stop
  silence_stream(STDOUT) do
    pid = File.read(pid_file)
    system("kill -9 #{pid}")
    FileUtils.rm_f pid_file
  end
end