diff options
author | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2012-11-04 11:13:20 +0100 |
---|---|---|
committer | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2012-11-04 15:13:24 +0100 |
commit | dd365198e5a718c77ed960ac80d8ba32a6d10bfe (patch) | |
tree | ca6b52be7368c4fa5c2d0480b03732766e4561b1 /lib | |
parent | 6de9a0e78c8d8ffe4e192daec0847d8852a437f0 (diff) | |
download | ecs2-dd365198e5a718c77ed960ac80d8ba32a6d10bfe.tar.gz ecs2-dd365198e5a718c77ed960ac80d8ba32a6d10bfe.zip |
auths garbage collection.
There is now a rake ecs:gc_sys_auths task. This task deletes all
outtimed auths resources. Maybe this task should be called frequently
from a cron job.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/ecs_garbage_collect_auths.rake | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/tasks/ecs_garbage_collect_auths.rake b/lib/tasks/ecs_garbage_collect_auths.rake new file mode 100644 index 0000000..606ae82 --- /dev/null +++ b/lib/tasks/ecs_garbage_collect_auths.rake @@ -0,0 +1,24 @@ +namespace :ecs do + desc "Deletes outtimed authorization tokens." + task :gc_sys_auths => :environment do + ps= `ps ax | grep -v 'grep' | grep -v "^[ \t]*#{Process.pid}" | grep 'rake ecs:gc_sys_auths'` + if !ps.empty? + RAILS_DEFAULT_LOGGER.info "GC: there is already running a ecs:gc_sys_auths process. Aborting." + puts "GC: There is already running a ecs:gc_sys_auths process. Aborting." + exit 1 + end + RAILS_DEFAULT_LOGGER.info "GC: Searching for outtimed auths ..." + puts "GC: Searching for outtimed auths ..." + Message.all.each do |m| + if m.auth + if ! m.test_auths_validation_window + m.destroy_as_sender + RAILS_DEFAULT_LOGGER.info "GC: garbage collect auths token with id=#{m.id}." + puts "delete outtimed authorization token with id=#{m.id}" + end + end + end + RAILS_DEFAULT_LOGGER.info "GC: Searching for outtimed auths done." + puts "GC: Searching for outtimed auths done." + end +end |