Sha256: 53ba9f5a2067a2371977c8e2bf02504d3579d0f5520222f009d59ef2256f3c08

Contents?: true

Size: 691 Bytes

Versions: 13

Compression:

Stored size: 691 Bytes

Contents

require 'flydata'
require 'flydata/helper/base_action'

module Flydata
  module Helper
    module Action
      class CheckAbnormalShutdown < BaseAction
        def execute(opts = {})
          if abnormal_shutdown_occurred?
            log_info "Abnormal shutdown occurred.  Restart the agent."
            yield :restart_agent, nil
          end
        end

        private
        def abnormal_shutdown_occurred?
          File.exists?(FLYDATA_LOCK) && !process_exists?(File.open(FLYDATA_LOCK){|f| f.read})
        end

        def process_exists?(pid)
          Process.getpgid(pid.to_i)
          true
        rescue Errno::ESRCH
          false
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
flydata-0.6.2 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.6.1 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.6.0 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.21 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.20 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.17 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.16 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.15 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.14 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.13 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.12 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.11 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.5.10 lib/flydata/helper/action/check_abnormal_shutdown.rb