Class: Uma::CLI::Serve

Inherits:
Base
  • Object
show all
Defined in:
lib/uma/cli.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#argv, #env

Instance Method Summary collapse

Methods inherited from Base

#print_message

Constructor Details

#initialize(argv, env) ⇒ Serve

Returns a new instance of Serve.



127
128
129
130
131
# File 'lib/uma/cli.rb', line 127

def initialize(argv, env)
  super
  server_class = env[:server_class] || Uma::Server
  @server = server_class.new(@env)
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



125
126
127
# File 'lib/uma/cli.rb', line 125

def server
  @server
end

Instance Method Details

#runObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/uma/cli.rb', line 133

def run
  parse_argv

  print_message(@env[:io_err], SERVE_BANNER)
  @server.start
rescue => e
  if env[:error_handler]
    env[:error_handler].(e)
  else
    ErrorResponse.new(e, @argv, @env).run
  end
ensure
  @server.stop
end