Sha256: a02d2e74542fc9be8a391a04c311ef3f4580da54bf70e34d90fae70d8b75f9a8

Contents?: true

Size: 1.36 KB

Versions: 55

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require 'puma/runner'
require 'puma/detect'
require 'puma/plugin'

module Puma
  # 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.
  class Single < Runner
    # @!attribute [r] stats
    def stats
      {
        started_at: @started_at.utc.iso8601
      }.merge(@server.stats)
    end

    def restart
      @server.begin_restart
    end

    def stop
      @server.stop(false) if @server
    end

    def halt
      @server.halt
    end

    def stop_blocked
      log "- Gracefully stopping, waiting for requests to finish"
      @control.stop(true) if @control
      @server.stop(true) if @server
    end

    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
  end
end

Version data entries

55 entries across 52 versions & 5 rubygems

Version Path
puma-5.6.9-java lib/puma/single.rb
puma-5.6.9 lib/puma/single.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/puma-5.6.8/lib/puma/single.rb
puma-5.6.8-java lib/puma/single.rb
puma-5.6.8 lib/puma/single.rb
puma-5.6.7-java lib/puma/single.rb
puma-5.6.7 lib/puma/single.rb
puma-5.6.6-java lib/puma/single.rb
puma-5.6.6 lib/puma/single.rb
puma-5.6.5-java lib/puma/single.rb
puma-5.6.5 lib/puma/single.rb
puma-5.6.4-java lib/puma/single.rb
puma-5.6.4 lib/puma/single.rb
puma-5.6.2-java lib/puma/single.rb
puma-5.6.2 lib/puma/single.rb
puma-5.6.1-java lib/puma/single.rb
puma-5.6.1 lib/puma/single.rb
puma-5.6.0-java lib/puma/single.rb
puma-5.6.0 lib/puma/single.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/puma-5.5.2/lib/puma/single.rb