diff --git a/lib/tasks/deployment/20340720232939_store_deploy_time.rake b/lib/tasks/deployment/20340720232939_store_deploy_time.rake deleted file mode 100644 index c2e33a75a4..0000000000 --- a/lib/tasks/deployment/20340720232939_store_deploy_time.rake +++ /dev/null @@ -1,29 +0,0 @@ -namespace :after_party do - desc "Deployment task: stores_the_time_of_the_latest_deploy_as_a_file" - task store_deploy_time: :environment do - puts "Running deploy task 'store_deploy_time'" unless Rails.env.test? - - status = with_captured_stdout { Rake::Task['after_party:status'].invoke } - status_array = status.split("\n") - - # filter out store deploy time (this file) because recurring tasks always show as down - status_array = status_array.reject { |line| line.include?("20340720232939 Store deploy time")} - # look for other tasks that are down - down_tasks = status_array.select { |line| line.starts_with?(" down")} - - if down_tasks.empty? - puts("SHOULD BE CALLED BECAUSE NO DOWN TASKS #{down_tasks}") - Health.instance.update_attribute(:latest_deploy_time, Time.now) - end - end -end - -# Stole this from stack overflow -def with_captured_stdout - original_stdout = $stdout # capture previous value of $stdout - $stdout = StringIO.new # assign a string buffer to $stdout - yield # perform the body of the user code - $stdout.string # return the contents of the string buffer -ensure - $stdout = original_stdout # restore $stdout to its previous value -end diff --git a/lib/tasks/deployment/99991023145114_store_deploy_time.rake b/lib/tasks/deployment/99991023145114_store_deploy_time.rake new file mode 100644 index 0000000000..d97ba397a4 --- /dev/null +++ b/lib/tasks/deployment/99991023145114_store_deploy_time.rake @@ -0,0 +1,14 @@ +namespace :after_party do + desc "Deployment task: stores_the_time_of_the_latest_deploy_as_a_file" + task store_deploy_time: :environment do + puts "Running deploy task 'store_deploy_time'" unless Rails.env.test? + pending_files = AfterParty::TaskRecorder.pending_files + + down_tasks = pending_files.reject { |item| item.task_name == "store_deploy_time" } + if down_tasks.empty? + Health.instance.update_attribute(:latest_deploy_time, Time.now) + else + puts("failed tasks found, latest_deploy_time will not be updated!") + end + end +end