Sha256: d7514bd9b8f80a2fb7626e7a322af5e6d5deca2d51f0536af11944640940c8ed

Contents?: true

Size: 1.94 KB

Versions: 66

Compression:

Stored size: 1.94 KB

Contents

require 'puma/runner'

module Puma
  class Single < Runner
    def stats
      b = @server.backlog
      r = @server.running
      %Q!{ "backlog": #{b}, "running": #{r} }!
    end

    def restart
      @server.begin_restart
    end

    def stop
      @server.stop false
    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)
    end

    def jruby_daemon?
      daemon? and @cli.jruby?
    end

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

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

        load_and_bind
      end

      @cli.write_state

      start_control

      @server = server = start_server

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

      @cli.events.fire_on_booted!

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

Version data entries

66 entries across 63 versions & 15 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/puma-2.16.0-java/lib/puma/single.rb