Class: OneApm::Agent::RestartMonitor
- Inherits:
-
Object
- Object
- OneApm::Agent::RestartMonitor
- Defined in:
- lib/one_apm/agent/agent/restart_monitor.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_restart_file ⇒ Object
-
#initialize ⇒ RestartMonitor
constructor
A new instance of RestartMonitor.
Constructor Details
#initialize ⇒ RestartMonitor
Returns a new instance of RestartMonitor.
7 8 9 10 |
# File 'lib/one_apm/agent/agent/restart_monitor.rb', line 7 def initialize @lock = Mutex.new create_restart_file end |
Class Method Details
.need_restart? ⇒ Boolean
29 30 31 32 33 |
# File 'lib/one_apm/agent/agent/restart_monitor.rb', line 29 def self.need_restart? @result = == self. = unless @result !@result end |
.touch ⇒ Object
35 36 37 |
# File 'lib/one_apm/agent/agent/restart_monitor.rb', line 35 def self.touch !file_path.nil? && system("touch #{file_path}") end |
Instance Method Details
#create_restart_file ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/one_apm/agent/agent/restart_monitor.rb', line 12 def create_restart_file @lock.synchronize do begin file_path = OneApm::Agent::RestartMonitor.file_path return if file_path.nil? if !File.exist?(file_path) && system("touch #{file_path}") OneApm::Manager.logger.info "create #{file_path} successful." else OneApm::Manager.logger.debug "#{file_path} has exist." end OneApm::Agent::RestartMonitor. = File.mtime(file_path).to_i rescue => e OneApm::Manager.logger.warn("create #{file_path} fail.", e) end end end |