22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/daikon/daemon.rb', line 22
def self.start(argv, ontop = false)
self.run = true
config = Daikon::Configuration.new(argv)
if argv.include?("-v") || argv.include?("--version")
puts "Daikon v#{VERSION}"
return
end
Daemons.run_proc("daikon", :ARGV => argv, :log_output => true, :backtrace => true, :ontop => ontop) do
if argv.include?("run")
logger = Logger.new(STDOUT)
else
logger = Logger.new("/tmp/radish.log")
end
if port = ENV["PORT"]
logger.info "Port detected, starting server on port #{port}"
Daikon::Server.start(logger, port)
end
rotated_at = reported_at = Time.now
client = Daikon::Client.new
client.setup(config, logger)
client.start_monitor
while self.run do
now = Time.now
if now - reported_at >= sleep_time * INFO_INTERVAL.to_i
client.report_info
reported_at = now
end
if now - rotated_at >= sleep_time * SUMMARY_INTERVAL.to_i
client.rotate_monitor(rotated_at, now)
rotated_at = now
end
sleep sleep_time
end
end
end
|