diff options
author | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2012-11-29 16:56:26 +0100 |
---|---|---|
committer | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2012-11-29 17:27:05 +0100 |
commit | f59b78503c3e6ee39d13a0b1a959784cccca5da6 (patch) | |
tree | ea5d07cfda391d87299f09584b3c67a54319769a /lib | |
parent | 1ddc5940e52d8db00ba204f99679bc5a271c425b (diff) | |
download | ecs2-f59b78503c3e6ee39d13a0b1a959784cccca5da6.tar.gz ecs2-f59b78503c3e6ee39d13a0b1a959784cccca5da6.zip |
Moved gc auth code to auths model.
Further made some testcode for auths handling.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/ecs_garbage_collect_auths.rake | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/lib/tasks/ecs_garbage_collect_auths.rake b/lib/tasks/ecs_garbage_collect_auths.rake index 74ba324..c5dd29f 100644 --- a/lib/tasks/ecs_garbage_collect_auths.rake +++ b/lib/tasks/ecs_garbage_collect_auths.rake @@ -1,49 +1,6 @@ namespace :ecs do - desc "Deletes outtimed authorization tokens (needs ps system command)." + desc "Delete outtimed authorization tokens." task :gc_sys_auths => :environment do - gc_sys_auths_pid= "#{Rails.root}/tmp/pids/gc_sys_auths.pid" - if File.exists?(gc_sys_auths_pid) - pid= "" - gc_sys_auths_is_running= false - File.open(gc_sys_auths_pid,"r") do |f| - pid= f.readline.strip - end - p= open("|ps ax") - p.each_line do |line| - if line.index(pid) - gc_sys_auths_is_running= true - break - end - end - p.close - if gc_sys_auths_is_running - RAILS_DEFAULT_LOGGER.info "GC: there seems to be already running a ecs:gc_sys_auths process (#{gc_sys_auths_pid}). Aborting." - puts "GC: there seems to be already running a ecs:gc_sys_auths process (#{gc_sys_auths_pid}). Aborting." - raise 'gc_sys_auths.pid file exists!' - end - end - File.open(gc_sys_auths_pid,"w") do |f| - f.puts "#{Process.pid}" - end - begin - 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." - ensure - begin - #File.delete(gc_sys_auths_pid) - rescue - end - end + Auth.gc_outtimed end end |