diff options
author | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2014-07-30 00:49:08 +0200 |
---|---|---|
committer | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2016-01-27 01:51:19 +0100 |
commit | d3d24952b04364a6615ea93fafdf474884448030 (patch) | |
tree | 08f56e4308918e64d14cd1ccc9aa941f49d64cd1 | |
parent | 7a5d965cd7abdbd6d3add2e699e247ba48c17ead (diff) | |
download | ecs2-d3d24952b04364a6615ea93fafdf474884448030.tar.gz ecs2-d3d24952b04364a6615ea93fafdf474884448030.zip |
New rake task vip:gc_results.
Delete old results. You have to edit the task file to change the time from when
the results will be deleted.
-rw-r--r-- | lib/tasks/vip_garbage_collect_results.rake | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/tasks/vip_garbage_collect_results.rake b/lib/tasks/vip_garbage_collect_results.rake new file mode 100644 index 0000000..d640447 --- /dev/null +++ b/lib/tasks/vip_garbage_collect_results.rake @@ -0,0 +1,19 @@ +namespace :vip do + desc "Delete old results." + task :gc_results => :environment do + # ttl= 20*60 # 20 minutes + ttl= 1.month + timenow= Time.now + i=0 + Message.for_resource("numlab", "results").each do |msg| + if msg.created_at < (timenow - ttl) + i+=1 + Message::destroy_msg(msg) + txt= "Service: garbage collect result: #{msg.ressource.namespace}/#{msg.ressource.ressource}/#{msg.id.to_s}" + RAILS_DEFAULT_LOGGER.info txt + #puts txt + end + end + puts "\nDeleted #{i} results." + end +end |