class Eir::Server
Public Class Methods
new()
click to toggle source
# File lib/eir/server.rb, line 3 def initialize @server_url = 'http://localhost:8700' end
Public Instance Methods
start()
click to toggle source
# File lib/eir/server.rb, line 25 def start stop if File.exist? 'server.pid' puts "Starting the server at #{@server_url}" `bundle exec puma --config #{File.dirname(__FILE__)}/app/puma.rb` Timeout.timeout(10, FailedToStartSinatraError) { sleep 1 until status == 200 } end
status()
click to toggle source
# File lib/eir/server.rb, line 19 def status RestClient.get("#{@server_url}/status").code rescue Errno::ECONNREFUSED false end
stop()
click to toggle source
# File lib/eir/server.rb, line 32 def stop pid = File.read('server.pid').to_i puts "Destroying the server process ID: #{pid}" `kill -9 #{pid}` Timeout.timeout(10, FailedToStopSinatraError) { sleep 1 until status == false } end