Sha256: d49ec2c544d1f8df5aed8ae46b9c4ec84ee2925d793302d7415735aef7e589b8

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

module Daemons
  class Reporter
    attr_reader :options

    def initialize(options)
      @options = options

      if !options[:shush]
        $stdout.sync = true
      end
    end

    def output_message(message)
      if !options[:shush]
        puts message
      end
    end

    def changing_process_privilege(user, group = user)
      output_message "Changing process privilege to #{user}:#{group}"
    end

    def deleted_found_pidfile(pid, f)
      output_message "pid-file for killed process #{pid} found (#{f}), deleting."
    end

    def process_started(app_name, pid)
      output_message  "#{app_name}: process with pid #{pid} started."
    end

    def backtrace_not_supported 
      output_message 'option :backtrace is not supported with :mode => :exec, ignoring'
    end

    def stopping_process(app_name, pid, sig, wait)
      output_message "#{app_name}: trying to stop process with pid #{pid}#{' forcefully :(' if sig == 'KILL'} sending #{sig} and waiting #{wait}s ..."
      $stdout.flush
    end

    def cannot_stop_process(app_name, pid)
      output_message "#{app_name}: unable to forcefully kill process with pid #{pid}."
      $stdout.flush
    end

    def stopped_process(app_name, pid)
      output_message "#{app_name}: process with pid #{pid} successfully stopped."
      $stdout.flush
    end

    def status(app_name, running, pid_exists, pid)
      output_message "#{app_name}: #{running ? '' : 'not '}running#{(running and pid_exists) ? ' [pid ' + pid.to_s + ']' : ''}#{(pid_exists and not running) ? ' (but pid-file exists: ' + pid.to_s + ')' : ''}"
    end
  end
end

Version data entries

5 entries across 3 versions & 2 rubygems

Version Path
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/2.6.0/gems/daemons-1.4.1/lib/daemons/reporter.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.0.0/gems/daemons-1.4.1/lib/daemons/reporter.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.1.0/gems/daemons-1.4.1/lib/daemons/reporter.rb
daemons-1.4.1 lib/daemons/reporter.rb
daemons-1.4.0 lib/daemons/reporter.rb