Class: MinionServer

Inherits:
Object
  • Object
show all
Defined in:
lib/minion_server.rb

Constant Summary collapse

VERSION =
"0.0.2"

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ MinionServer

Returns a new instance of MinionServer.



7
8
9
# File 'lib/minion_server.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#shutdownObject



34
35
36
37
38
# File 'lib/minion_server.rb', line 34

def shutdown
  #puts "== Stopping #{@app.inspect}\n\n"
  Process.kill(:INT, @pid_server) # send ctrl+c to webrick
  Process.waitpid(@pid_server) # waiting his life go to void ...
end

#start(host = "localhost", port = 4000, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/minion_server.rb', line 11

def start(host = "localhost", port = 4000, options = {})
  #puts "== Starting #{@app.inspect}"
  @pid_server = fork do
    server_options = {
      :app => @app,
      :server => 'webrick',
      :environment => :none,
      :daemonize => false,
      :Host => host,
      :Port => port
    }

    if options[:mute]
      server_options[:Logger] = Logger.new("/dev/null")
      server_options[:AccessLog] = [nil, nil]
    end

    Rack::Server.start(server_options)
  end
  wait_for_service(host, port)
  self
end