Permalink
Browse files

fixed a problem with directive persistence and clarified logging mess…

…ages
  • Loading branch information...
1 parent 54285b6 commit 9e64227ff938464b9bf8ec5f5bfe8f2f6af1fc46 Andre Lewis committed Nov 30, 2009
Showing with 11 additions and 6 deletions.
  1. +5 −2 lib/scout/command/run.rb
  2. +6 −4 lib/scout/server.rb
@@ -18,12 +18,15 @@ def run
end
# END: Experimental -- may not keep this
- if @scout.checkin_now || @force
+ if @scout.checkin_now || @force
+ if log
+ log.info(@scout.checkin_now ? "It is time to checkin" : "overriding checkin time with --force and checking in now.")
+ end
create_pid_file_or_exit
@scout.run_plugins_by_plan
@scout.save_history
else
- log.info "Not time to checkin yet" if log
+ log.info "Not time to checkin yet. Override by passing --force to the scout command" if log
end
end
end
View
@@ -67,18 +67,19 @@ def initialize(server, client_key, history_file, logger = nil)
# 2) it sets @checkin_to = true IF so directed by the scout server
def fetch_plan
url = urlify(:plan)
- info "Loading plan from #{url}..."
+ info "Pinging server at #{url}..."
headers = Hash.new
if @history["plan_last_modified"] and @history["old_plugins"]
headers["If-Modified-Since"] = @history["plan_last_modified"]
end
get(url, "Could not retrieve plan from server.", headers) do |res|
@checkin_now = res['X-checkin-now'] == 'true'
if res.is_a? Net::HTTPNotModified
- info "Plan not modified. Reusing saved plan."
+ info "Plan not modified. Will reuse saved plan."
@plugin_plan = Array(@history["old_plugins"])
- @directives = @history["directives"]
+ @directives = @history["directives"] || Hash.new
else
+ info "plan has been modified; running the new plan now."
begin
body = res.body
if res["Content-Encoding"] == "gzip" and body and not body.empty?
@@ -90,7 +91,8 @@ def fetch_plan
@directives = body_as_hash["directives"].is_a?(Hash) ? body_as_hash["directives"] : Hash.new
if res["Last-Modified"]
@history["plan_last_modified"] = res["last-modified"]
- @history["old_plugins"] = @plugin_plan
+ @history["old_plugins"] = @plugin_plan
+ @history["directives"] = @directives
end
info "Plan loaded. (#{@plugin_plan.size} plugins: " +
"#{@plugin_plan.map { |p| p['name'] }.join(', ')})" +

0 comments on commit 9e64227

Please sign in to comment.