lib/splash/cli/daemon.rb in prometheus-splash-0.3.0 vs lib/splash/cli/daemon.rb in prometheus-splash-0.4.0

- old
+ new

@@ -3,10 +3,11 @@ class CLIController < Thor include Splash::LogsMonitor::DaemonController include Splash::Transports include Splash::Exiter + include Splash::Loggers option :foreground, :type => :boolean option :purge, :type => :boolean, default: true option :scheduling, :type => :boolean, default: true @@ -16,34 +17,36 @@ With --no-scheduling, inhibit commands scheduling\n With --no-purge, inhibit purge Input Queue for Splash Daemon LONGDESC desc "start", "Starting Splash Daemon" def start + log = get_logger if options[:purge] then transport = get_default_client if transport.class == Hash and transport.include? :case then splash_exit transport else queue = "splash.#{Socket.gethostname}.input" transport.purge queue: queue - puts " * Queue : #{queue} purged" + log.info "Queue : #{queue} purged" end end acase = run_as_root :startdaemon, options splash_exit acase end desc "purge", "Purge Transport Input queue of Daemon" def purge + log = get_logger transport = get_default_client if transport.class == Hash and transport.include? :case then splash_exit transport else queue = "splash.#{Socket.gethostname}.input" transport.purge queue: queue - puts " * Queue : #{queue} purged" + log.ok "Queue : #{queue} purged" splash_exit case: :quiet_exit end end desc "stop", "Stopping Splash Daemon" @@ -58,16 +61,17 @@ splash_exit acase end desc "ping HOSTNAME", "send a ping to HOSTNAME daemon over transport (need an active tranport), Typicallly RabbitMQ" def ping(hostname=Socket.gethostname) - puts "ctrl+c for interrupt" + log = get_logger + log.info "ctrl+c for interrupt" begin transport = get_default_client if transport.class == Hash and transport.include? :case then splash_exit transport else - puts transport.execute({ :verb => :ping, + log.receive transport.execute({ :verb => :ping, :payload => {:hostname => Socket.gethostname}, :return_to => "splash.#{Socket.gethostname}.returncli", :queue => "splash.#{hostname}.input" }) splash_exit case: :quiet_exit end