class Puma::Single - puma-3.11.4 Documentation

# class Puma::Single

### Public Instance Methods

halt() click to toggle source

    # File lib/puma/single.rb, line 21
    def halt
      @server.halt
    end

jruby_daemon?() click to toggle source

    # File lib/puma/single.rb, line 31
    def jruby_daemon?
      daemon? and Puma.jruby?
    end

jruby_daemon_start() click to toggle source

    # File lib/puma/single.rb, line 35
    def jruby_daemon_start
      require 'puma/jruby_restart'
      JRubyRestart.daemon_start(@restart_dir, @launcher.restart_args)
    end

restart() click to toggle source

    # File lib/puma/single.rb, line 13
    def restart
      @server.begin_restart
    end

run() click to toggle source

    # File lib/puma/single.rb, line 40
    def run
      already_daemon = false

      if jruby_daemon?
        require 'puma/jruby_restart'

        if JRubyRestart.daemon?
          # load and bind before redirecting IO so errors show up on stdout/stderr
          load_and_bind
          redirect_io
        end

        already_daemon = JRubyRestart.daemon_init
      end

      output_header "single"

      if jruby_daemon?
        if already_daemon
          JRubyRestart.perm_daemonize
        else
          pid = nil

          Signal.trap "SIGUSR2" do
            log "* Started new process #{pid} as daemon..."

            # Must use exit! so we don't unwind and run the ensures
            # that will be run by the new child (such as deleting the
            # pidfile)
            exit!(true)
          end

          Signal.trap "SIGCHLD" do
            log "! Error starting new process as daemon, exiting"
            exit 1
          end

          jruby_daemon_start
          sleep
        end
      else
        if daemon?
          log "* Daemonizing..."
          Process.daemon(true)
          redirect_io
        end

        load_and_bind
      end

      Plugins.fire_background

      @launcher.write_state

      start_control

      @server = server = start_server

      unless daemon?
        log "Use Ctrl-C to stop"
        redirect_io
      end

      @launcher.events.fire_on_booted!

      begin
        server.run.join
      rescue Interrupt
        # Swallow it
      end
    end

stats() click to toggle source

    # File lib/puma/single.rb, line 7
    def stats
      b = @server.backlog || 0
      r = @server.running || 0
      %Q!{ "backlog": #{b}, "running": #{r} }!
    end

stop() click to toggle source

    # File lib/puma/single.rb, line 17
    def stop
      @server.stop false
    end

stop_blocked() click to toggle source

    # File lib/puma/single.rb, line 25
    def stop_blocked
      log "- Gracefully stopping, waiting for requests to finish"
      @control.stop(true) if @control
      @server.stop(true)
    end