class Puma::Single

This class is instantiated by the `Puma::Launcher` and used to boot and serve a Ruby application when no puma “workers” are needed i.e. only using “threaded” mode. For example `$ puma -t 1:5`

At the core of this class is running an instance of `Puma::Server` which gets created via the `start_server` method from the `Puma::Runner` class that this inherits from.

Public Instance Methods

halt() click to toggle source
# File lib/puma/single.rb, line 30
def halt
  @server.halt
end
restart() click to toggle source
# File lib/puma/single.rb, line 22
def restart
  @server.begin_restart
end
run() click to toggle source
# File lib/puma/single.rb, line 40
def run
  output_header "single"

  load_and_bind

  Plugins.fire_background

  @launcher.write_state

  start_control

  @server = server = start_server
  server_thread = server.run

  log "Use Ctrl-C to stop"
  redirect_io

  @launcher.events.fire_on_booted!

  begin
    server_thread.join
  rescue Interrupt
    # Swallow it
  end
end
stats() click to toggle source

@!attribute [r] stats

# File lib/puma/single.rb, line 16
def stats
  {
    started_at: @started_at.utc.iso8601
  }.merge(@server.stats)
end
stop() click to toggle source
# File lib/puma/single.rb, line 26
def stop
  @server.stop(false) if @server
end
stop_blocked() click to toggle source
# File lib/puma/single.rb, line 34
def stop_blocked
  log "- Gracefully stopping, waiting for requests to finish"
  @control.stop(true) if @control
  @server.stop(true) if @server
end