Class: Flapjack::Pikelet::HTTP
Constant Summary collapse
- TYPES =
['jsonapi', 'web']
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#reload(cfg) ⇒ Object
this should only reload if all changes can be applied – will return false to log warning otherwise.
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from Flapjack::Pikelet::Base
Instance Method Details
#reload(cfg) ⇒ Object
this should only reload if all changes can be applied – will return false to log warning otherwise
190 191 192 193 194 |
# File 'lib/flapjack/pikelet.rb', line 190 def reload(cfg) # TODO handle bind_address/port changes by changing listeners? return false unless @pikelet_class.respond_to?(:reload) super(cfg) { @pikelet_class.reload(cfg) } end |
#start ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/flapjack/pikelet.rb', line 166 def start @pikelet_class.instance_variable_set('@config', @config) if @config bind_address = @config['bind_address'] port = @config['port'] port = port.nil? ? nil : port.to_i timeout = @config['timeout'] timeout = timeout.nil? ? 300 : timeout.to_i end bind_address = '127.0.0.1' if bind_address.nil? port = 3001 if (port.nil? || port <= 0 || port > 65535) super do @pikelet_class.start if @pikelet_class.respond_to?(:start) @server = ::Puma::Server.new(@pikelet_class) @server.binder.add_tcp_listener(bind_address, port) yield @server if block_given? @server.run(false) # no background run, use current thread end end |
#stop ⇒ Object
196 197 198 199 200 201 202 203 204 205 |
# File 'lib/flapjack/pikelet.rb', line 196 def stop super do |thread| unless @server.nil? Flapjack.logger.info "shutting down server" @server.stop(true) # no background stop, wait for requests to finish Flapjack.logger.info "shut down server" end @pikelet_class.stop(thread) if @pikelet_class.respond_to?(:stop) end end |