Sha256: 4595a7df112a09542459f373e94423c4b8a655eb647fea517f66236a7080fa58
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
#!/usr/bin/env ruby # Trap interrupts to quit cleanly Signal.trap('INT') { abort } lib = File.expand_path('../../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) # Store a list of options given by the OptionParser options = { sleep: 1_000, } # Make our OptionParser (we haven't loaded Falcore yet) require 'optparse' parser = OptionParser.new do |opts| opts.banner = "Usage: #{$PROGRAM_NAME} [OPTIONS]" opts.on('-c', '--config [PATH]', 'Path to a Falcore config') do |path| options[:config] = File.expand_path(path, Dir.pwd) end opts.on('-d', '--daemon', 'Run process as a daemon') do options[:daemon] = true end opts.on('-s', '--sleep [TIME]', 'Time (ms) to sleep before recalculating') do |value| options[:sleep] = value.to_f end opts.on_tail('-h', '--help', 'Show this message') do puts opts exit(0) end opts.on_tail('-v', '--version', 'Show current Falcore version') do require 'falcore/version' puts Falcore::VERSION exit(0) end end # Parse the options begin parser.parse! # Raise an exception if we have not be given a config path raise OptionParser::MissingArgument, '--config' if options[:config].nil? rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e puts e.to_s puts puts parser exit(1) end # If we got this far, we should actually load up Falcore require 'falcore' # Load the config before looping. If you change the config, restart the process. # Config parsing is rather expensive. config = Falcore::Config.from_file(options[:config]) # Run as a daemon if we asked to if options[:daemon] Process.daemon(true) end # Just keep swimming... loop do master = Falcore::Aggregator.new(config).run unless config.statsd.nil? Falcore::Dumper::Statsd.new(config, master).run end unless config.dogstatsd.nil? Falcore::Dumper::DogStatsd.new(config, master).run end sleep(options[:sleep]/1_000) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
falcore-0.2.0 | bin/falcore |