Created
April 12, 2018 01:48
-
-
Save marzdgzmn/00c308f2e9cc964f7ff5d8c80e9ed21b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'concurrent' | |
require 'pry' | |
#require_relative '../lib/mirror_rsync' | |
require_relative '../lib/beaneater_config' | |
require_relative '../lib/mirror_observer' | |
require_relative '../lib/rise_mirror_app' | |
require_relative '../lib/rise_exceptions' | |
require_relative '../lib/mirror_status' | |
require_relative '../lib/mirror' | |
require_relative '../lib/mirrorsync' | |
class Sync | |
include RiseMirrorApp | |
include Mirror | |
include MirrorSync | |
Concurrent.use_stdlib_logger(Logger::DEBUG) | |
def self.run | |
Sync.new.run | |
end | |
def initialize | |
@mirrors = Mirror::Strategies::MirrorIniFileLoader.retrieve_upstream_mirror_configuration | |
@pool = Concurrent::FixedThreadPool.new(10, max_queue: 20) #Given a fileserver only syncs for a maximum of 30 mirrors | |
@mirror_observer = MirrorObserver.new | |
end | |
def run | |
puts 'running' | |
@mirrors.each do |mirror| | |
future = Concurrent::Future.new(executor: @pool) { | |
@mirror_observer.mirror_rsync_start(Time.now, mirror[:name]) | |
MirrorSync::Strategies::MirrorRsync.sync(mirror) | |
} | |
future.add_observer(@mirror_observer, :mirror_rsync_end) | |
future.execute | |
sleep 60 | |
#binding.pry | |
end | |
end | |
end | |
Sync.run | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment