Sha256: 263107239d474f5f4854d27b1e1214b8f8d629279cbd5a1cfb57017307390c5d

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require_relative 'version'

module Puma
  module Daemon
    module RunnerAdapter
      class << self
        def included(base)
          base.class_eval do
            attr_reader :options
            attr_accessor :has_demonized
          end

          base.class_eval do
            def output_header(mode)
              super(mode)

              daemonize! if daemon?
            end

            def daemon?
              options[:daemon]
            end

            def daemonize!
              return if has_demonized

              log '*  Puma Daemon: Demonizing...'
              log "*  Gem: puma-daemon v#{::Puma::Daemon::VERSION}"
              log "*  Gem: puma v#{::Puma::Const::VERSION}"

              Process.daemon(true, true)
              self.has_demonized = true
            end

            def log(str)
              if super.respond_to?(:log)
                super(str) unless str == 'Use Ctrl-C to stop'
              else
                puts(str)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puma-daemon-0.3.0 lib/puma/daemon/runner_adapter.rb
puma-daemon-0.2.3 lib/puma/daemon/runner_adapter.rb