Skip to content
Browse files

removed some unneeded stuff

  • Loading branch information...
1 parent 3ae064b commit 2068ac352cea771f02c5c9d1e21283801f93fb63 Andre Lewis committed Nov 30, 2009
Showing with 14 additions and 9 deletions.
  1. +14 −9 lib/scout/server.rb
View
23 lib/scout/server.rb
@@ -57,12 +57,6 @@ def initialize(server, client_key, history_file, logger = nil)
end
end
- def run
-
- end
-
-
-
#
# Retrieves the Plugin Plan from the server. This is the list of plugins
# to execute, along with all options.
@@ -93,12 +87,11 @@ def fetch_plan
body_as_hash = JSON.parse(body)
@plugin_plan = Array(body_as_hash["plugins"])
@directives = body_as_hash["directives"].is_a?(Hash) ? body_as_hash["directives"] : Hash.new
- # TODO: I can't think of any reason this conditional is needed
- #if res["Last-Modified"]
+
@history["plan_last_modified"] = res["last-modified"]
@history["old_plugins"] = @plugin_plan
@history["directives"] = @directives
- #end
+
info "Plan loaded. (#{@plugin_plan.size} plugins: " +
"#{@plugin_plan.map { |p| p['name'] }.join(', ')})" +
". Directives: #{@directives.to_a.map{|a| "#{a.first}:#{a.last}"}.join(", ")}"
@@ -123,6 +116,18 @@ def time_to_checkin?
return true
end
+ # uses values from history and current time to determine if we should ping the server at this time
+ def time_to_ping?
+ return true if
+ @history['last_ping'] == nil ||
+ @directives['ping_interval'] == nil ||
+ (Time.now.to_i - Time.at(@history['last_ping']).to_i).abs+15 > @directives['ping_interval'].to_i*60
+ rescue
+ debug "Failed to calculate time_to_ping. @history['last_ping']=#{@history['last_ping']}. "+
+ "@directives['ping_interval']=#{@directives['ping_interval']}. Time.now.to_i=#{Time.now.to_i}"
+ return true
+ end
+
# returns a human-readable representation of the next checkin, i.e., 5min 30sec
def next_checkin
secs= @directives['interval'].to_i*60 - (Time.now.to_i - Time.at(@history['last_checkin']).to_i).abs

0 comments on commit 2068ac3

Please sign in to comment.
Something went wrong with that request. Please try again.