5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/rshare/exec.rb', line 5
def self.run!(args)
$opts = Options.parse!(args)
if ARGV.length < 2 or ARGV.first !~ /^push|pull$/
Options.parse! %w{--help}
end
$log = Logger.new($stdout, shift_age = 'weekly')
$log.level = $opts[:verbose] ? Logger::DEBUG : Logger::INFO
if $opts[:daemon]
$stdout.reopen File.open("./rshare.log", 'a')
Process.daemon(nochdir=true, noclose=true)
$log.info "Daemonized with PID #{Process.pid}"
end
confs = ARGV[1, ARGV.length].map { |f| Configuration.load(f) }
confs.each { |c| ARGV.first =~ /push/ ? RSync.push!(c) : RSync.pull!(c) }
$log.info "Exiting (PID #{Process.pid})"
end
|