Class: RailsServerMonitor::ServerSetup

Inherits:
Object
  • Object
show all
Defined in:
app/services/rails_server_monitor/server_setup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServerSetup

Returns a new instance of ServerSetup.



7
8
9
# File 'app/services/rails_server_monitor/server_setup.rb', line 7

def initialize
  @server = RailsServerMonitor::Server.find_or_initialize_by(hostname: hostname)
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



5
6
7
# File 'app/services/rails_server_monitor/server_setup.rb', line 5

def server
  @server
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
# File 'app/services/rails_server_monitor/server_setup.rb', line 11

def call
  server.tap do
    next update_server if server.updated_at.blank?

    needs_update = (Time.zone.now - server.updated_at) >= config.update_server_interval
    update_server if needs_update
  end
end