Repository: puma/puma
File: lib/puma/runner.rb (Ruby)

Code before:
    def close_control_listeners
      @control.binder.close_listeners if @control
    end

    # @!attribute [r] ruby_engine
    def ruby_engine
      if !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby"
        "ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
      else
        if defined?(RUBY_ENGINE_VERSION)
          "#{RUBY_ENGINE} #{RUBY_ENGINE_VERSION} - ruby #{RUBY_VERSION}"
        else
          "#{RUBY_ENGINE} #{RUBY_VERSION}"
        end
      end
    end

    def output_header(mode)
      min_t = @options[:min_threads]
      max_t = @options[:max_threads]

      log "Puma starting in #{mode} mode..."
      log "* Version #{Puma::Const::PUMA_VERSION} (#{ruby_engine}), codename: #{Puma::Const::CODE_NAME}"
      log "* Min threads: #{min_t}, max threads: #{max_t}"
      log "* Environment: #{ENV['RACK_ENV']}"
    end

    def redirected_io?
      @options[:redirect_stdout] || @options[:redirect_stderr]
    end

    def redirect_io
      stdout = @options[:redirect_stdout]
      stderr = @options[:redirect_stderr]
      append = @options[:redirect_append]

      if stdout
        unless Dir.exist?(File.dirname(stdout))
          raise "Cannot redirect STDOUT to #{stdout}"
        end

        STDOUT.reopen stdout, (append ? "a" : "w")
        STDOUT.sync = true
        STDOUT.puts "=== puma startup: #{Time.now} ==="
      end

      if stderr
        unless Dir.exist?(File.dirname(stderr))
          raise "Cannot redirect STDERR to #{stderr}"
        end


Review comment (suggestion):
I like this addition 👍

```suggestion
          "*         PID: #{Process.pid}"
```

How it would look like live:

```
$ bundle e bin/puma -p0 -C test/config/app.rb
Puma starting in single mode...
* Version 5.1.0 (ruby 2.7.1-p83), codename: At Your Service
* Min threads: 0, max threads: 5
* Environment: development
*         PID: 69955
* Listening on http://0.0.0.0:50084
Use Ctrl-C to stop
```


Some alternatives worth considering?

```
$ bundle e bin/puma -p0 -C test/config/app.rb
Puma starting in single mode...
* Version 5.1.0 (ruby 2.7.1-p83), codename: At Your Service
* Min threads: 0, max threads: 5
* Environment: development
* Process ID:  75834
* Listening on http://0.0.0.0:50746
Use Ctrl-C to stop
```

```
$ bundle e bin/puma -p0 -C test/config/app.rb
Puma starting in single mode...
* Version 5.1.0 (ruby 2.7.1-p83), codename: At Your Service
* Min threads: 0, max threads: 5
* Environment: development
* PID:         76584
* Listening on http://0.0.0.0:50824
Use Ctrl-C to stop
```

Code after:
    def close_control_listeners
      @control.binder.close_listeners if @control
    end

    # @!attribute [r] ruby_engine
    def ruby_engine
      if !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby"
        "ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
      else
        if defined?(RUBY_ENGINE_VERSION)
          "#{RUBY_ENGINE} #{RUBY_ENGINE_VERSION} - ruby #{RUBY_VERSION}"
        else
          "#{RUBY_ENGINE} #{RUBY_VERSION}"
        end
      end
    end

    def output_header(mode)
      min_t = @options[:min_threads]
      max_t = @options[:max_threads]

      log "Puma starting in #{mode} mode...\n" \
          "* Version #{Puma::Const::PUMA_VERSION} (#{ruby_engine}), codename: #{Puma::Const::CODE_NAME}\n" \
          "* Min threads: #{min_t}, max threads: #{max_t}\n" \
          "* Environment: #{ENV['RACK_ENV']}\n" \
          "*         Pid: #{Process.pid}"
    end

    def redirected_io?
      @options[:redirect_stdout] || @options[:redirect_stderr]
    end

    def redirect_io
      stdout = @options[:redirect_stdout]
      stderr = @options[:redirect_stderr]
      append = @options[:redirect_append]

      if stdout
        unless Dir.exist?(File.dirname(stdout))
          raise "Cannot redirect STDOUT to #{stdout}"
        end

        STDOUT.reopen stdout, (append ? "a" : "w")
        STDOUT.sync = true
        STDOUT.puts "=== puma startup: #{Time.now} ==="
      end

      if stderr
        unless Dir.exist?(File.dirname(stderr))
          raise "Cannot redirect STDERR to #{stderr}"
        end