Sha256: 5f0d910faca62209d8dd9b4f4a758d7c16e4a0a1eb8e62b692d28e0ce2b08c7a

Contents?: true

Size: 921 Bytes

Versions: 46

Compression:

Stored size: 921 Bytes

Contents

require 'flydata'
require 'flydata/command/base'
require 'flydata/helper/base_action'

module Flydata
  module Helper
    module Action
      class CheckAbnormalShutdown < BaseAction
        def execute(opts = {})
          if abnormal_shutdown_occurred?
            if Command::Base.command_process_exist?
              log_info "Abnormal shutdown occurred but another command is stil running.  Skip agent restart."
            else
              log_info "Abnormal shutdown occurred.  Restart the agent."
              yield :restart_agent, nil
            end
          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

46 entries across 46 versions & 1 rubygems

Version Path
flydata-0.8.10.2 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.10.1 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.9.11 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.10 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.9 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.8 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.7 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.6 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.5 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.4 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.3 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.2 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.1 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.8.0 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.7.19 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.7.18 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.7.17 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.7.16 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.7.15 lib/flydata/helper/action/check_abnormal_shutdown.rb
flydata-0.7.14 lib/flydata/helper/action/check_abnormal_shutdown.rb