Class: Myreplicator::Sweeper

Inherits:
Object
  • Object
show all
Defined in:
app/models/myreplicator/sweeper.rb

Class Method Summary collapse

Class Method Details

.performObject

Main method provided for resque Reconnection provided for resque workers



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/myreplicator/sweeper.rb', line 9

def self.perform
  Myreplicator::Log.clear_deads
  Myreplicator::Log.clear_stucks
  Myreplicator::Log.clear_olds
  ActiveRecord::Base.configurations.keys.each do |db|
    Myreplicator::VerticaLoader.clean_up_temp_tables(db)
  end

  #removing files that are left in the storage for more than 12 hours
  folders = [
    "#{Myreplicator.tmp_path}",
    "#{Myreplicator.configs[Myreplicator.configs.keys[1]]["ssh_tmp_dir"]}"
  ]

  folders.each do |folder|
    cmd = "find #{folder} -mmin +720"
    l = `#{cmd}`
    list = l.split(/\n/)
    list.each do |file|
      file.chomp!
      if File.file?(file)
        if (file.split('.').last == 'gz') || (file.split('.').last == 'json')
          puts "=== #{file}"
          File.delete(file)
        end
      end
    end
  end

end