From 4014f8ee47c2c2ee139de2654011014f008cbdda Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 3 Jul 2012 10:51:26 +0800 Subject: [PATCH] fix over queue at resque --- app/jobs/nccu_calendar.rb | 2 +- app/jobs/sync_db.rb | 5 +++-- config/resque_schedule.yml | 6 +++--- lib/tasks/mid_site_sync.rake | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/jobs/nccu_calendar.rb b/app/jobs/nccu_calendar.rb index e0676627..8756029d 100644 --- a/app/jobs/nccu_calendar.rb +++ b/app/jobs/nccu_calendar.rb @@ -16,6 +16,6 @@ end # FileUtils.mv(temp_file, File.join(Rails.root, 'public/static', 'nccu_calendar.xml')) - puts "NccuCalendar Synced4" + puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]NccuCalendar Synced" end end diff --git a/app/jobs/sync_db.rb b/app/jobs/sync_db.rb index f6e734cf..9c92e816 100644 --- a/app/jobs/sync_db.rb +++ b/app/jobs/sync_db.rb @@ -3,6 +3,7 @@ class SyncDb @queue = :high def self.perform() + puts "[ #{DateTime.now.strftime("%Y %D %H:%M") }]\t SyncDb Starting" self.start_sync self.set_admin end @@ -12,13 +13,13 @@ class SyncDb args = [] %x[rake #{task} --trace >> #{Rails.root}/log/rake.log] User.all.each{|ur| ur.create_dept_cache} - puts "SyncDb Synced" + puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]\tSyncDb Synced" end def self.set_admin task = 'mid_site:install_admin' args = [] %x[rake #{task} --trace >> #{Rails.root}/log/rake.log] - puts "Admin done" + puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]\tAdmin done" end end diff --git a/config/resque_schedule.yml b/config/resque_schedule.yml index 27af98fa..67d006ed 100644 --- a/config/resque_schedule.yml +++ b/config/resque_schedule.yml @@ -5,19 +5,19 @@ # description: Runs the perform method in FetchTime nccu_daily_ldap_sync: - cron: * * [0,12] * * * + cron: 0 0 [0,12] * * * class: SyncDb args: description: Sync NCCU middle site with Orbit for LDAP data nccu_daily_backup: - cron: * * 3 * * * + cron: 0 0 3 * * * class: BackupServer args: description: Backup NCCU site nccu_claender_sync: - cron: * * [0,12] * * * + cron: 0 0 [0,12] * * * class: NccuCalendar args: description: Sync NCCU calendar RSS Feeds \ No newline at end of file diff --git a/lib/tasks/mid_site_sync.rake b/lib/tasks/mid_site_sync.rake index 87979b66..69e93567 100644 --- a/lib/tasks/mid_site_sync.rake +++ b/lib/tasks/mid_site_sync.rake @@ -36,6 +36,7 @@ namespace :mid_site do local_need_remove = User.all.collect{|t| t.nccu_id rescue nil}.uniq.delete_if {|x| x == nil} - remote_list desc "Going to delete User with IDs: #{local_need_remove.inspect}" local_need_remove = User.excludes(nccu_ldap_uid: test_account_ldap_id ).collect{|t| t.nccu_ldap_uid rescue nil}.uniq.delete_if {|x| x == nil} - remote_list + AppManager.all.collect{|am| am if am.user.nil? }.delete_if {|x| x == nil}.each{|am| am.destroy} desc "Deletion completed! \n" #starting update user @@ -77,6 +78,7 @@ namespace :mid_site do local_user.save! end + end