Sha256: a7f1a7f802a7400b4df339c1463e16f9c31b6067edf4fc3ce454e23b3d602623

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Myreplicator
  class Sweeper

    @queue = :myreplicator_sweeper # Provided for Resque
    ##
    # Main method provided for resque
    # Reconnection provided for resque workers
    ##
    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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
myreplicator-1.1.73 app/models/myreplicator/sweeper.rb