lib/splash/daemon/controller.rb in prometheus-splash-0.5.3 vs lib/splash/daemon/controller.rb in prometheus-splash-0.6.0

- old
+ new

@@ -1,16 +1,29 @@ # coding: utf-8 +require 'splash/daemon/orchestrator' + +# base Splash module module Splash + + # global daemon module module Daemon + + # Daemon Controller Module module Controller include Splash::Constants include Splash::Helpers include Splash::Config include Splash::Exiter include Splash::Loggers include Splash::Daemon::Orchestrator + # Start the Splash Daemon + # @param [Hash] options + # @option options [Symbol] :quiet activate quiet mode for log (limit to :fatal) + # @option options [Symbol] :foreground run daemon in foreground + # @option options [Symbol] :purge clean input queue for daemon on configured transport + # @return [Hash] Exiter Case (:quiet_exit, :already_exist, :unknown_error or other) def startdaemon(options = {}) config = get_config log = get_logger log.level = :fatal if options[:quiet] unless verify_service host: config.prometheus_pushgateway_host ,port: config.prometheus_pushgateway_port then @@ -41,11 +54,11 @@ :stdout_trace => config.full_stdout_trace_path, :stderr_trace => config.full_stderr_trace_path, :foreground => options[:foreground] } - ["int","term","hup"].each do |type| daemon_config["sig#{type}_handler".to_sym] = Proc::new { ObjectSpace.each_object(Splash::Daemon::Orchestrator::Scheduler).first.shutdown } end + ["int","term","hup"].each do |type| daemon_config["sig#{type}_handler".to_sym] = Proc::new { ObjectSpace.each_object(Splash::Daemon::Orchestrator::Scheduler).first.terminate } end res = daemonize daemon_config do Scheduler::new options end sleep 1 if res == 0 then @@ -59,10 +72,14 @@ else return {:case => :already_exist, :more => "Pid File, please verify if Splash daemon is running."} end end + # Stop the Splash Daemon + # @param [Hash] options + # @option options [Symbol] :quiet activate quiet mode for log (limit to :fatal) + # @return [Hash] Exiter Case (:quiet_exit, :not_found, other) def stopdaemon(options = {}) config = get_config log = get_logger log.level = :fatal if options[:quiet] if File.exist?(config.full_pid_path) then @@ -78,9 +95,12 @@ acase = {:case => :not_found, :more => "Splash is not running"} end return acase end + # Status of the Splash Daemon, display status + # @param [Hash] options ignored + # @return [Hash] Exiter Case (:status_ko, :status_ok) def statusdaemon(options = {}) log = get_logger config = get_config pid = realpid = '' pid = `cat #{config.full_pid_path}`.to_s if File.exist?(config.full_pid_path)