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

- old
+ new

@@ -24,20 +24,20 @@ # @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 + unless verify_service url: config.prometheus_pushgateway_url then return {:case => :service_dependence_missing, :more => 'Prometheus Gateway'} end realpid = get_processes pattern: get_config.daemon_process_name foreground = get_processes patterns: [ "splash", "foreground" ] unless foreground.empty? or options[:foreground] then return {:case => :already_exist, :more => "Splash Process already launched on foreground "} end - unless File::exist? config.full_pid_path then + unless File::exist? config.daemon_full_pid_path then unless realpid.empty? then return {:case => :already_exist, :more => "Splash Process already launched "} end if options[:purge] then transport = get_default_client @@ -48,23 +48,23 @@ transport.purge queue: queue log.info "Queue : #{queue} purged" end end daemon_config = {:description => config.daemon_process_name, - :pid_file => config.full_pid_path, - :stdout_trace => config.full_stdout_trace_path, - :stderr_trace => config.full_stderr_trace_path, + :pid_file => config.daemon_full_pid_path, + :stdout_trace => config.daemon_full_stdout_trace_path, + :stderr_trace => config.daemon_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.terminate } end res = daemonize daemon_config do Scheduler::new options end sleep 1 if res == 0 then - pid = `cat #{config.full_pid_path}`.to_i + pid = `cat #{config.daemon_full_pid_path}`.to_i log.ok "Splash Daemon Started, with PID : #{pid}" return {:case => :quiet_exit, :more => "Splash Daemon successfully loaded."} else return {:case => :unknown_error, :more => "Splash Daemon loading error, see logs for more details."} end @@ -80,19 +80,19 @@ # @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 + if File.exist?(config.daemon_full_pid_path) then begin - pid = `cat #{config.full_pid_path}`.to_i + pid = `cat #{config.daemon_full_pid_path}`.to_i Process.kill("TERM", pid) acase = {:case => :quiet_exit, :more => 'Splash stopped succesfully'} rescue Errno::ESRCH acase = {:case => :not_found, :more => "Process of PID : #{pid} not found"} end - FileUtils::rm config.full_pid_path if File::exist? config.full_pid_path + FileUtils::rm config.daemon_full_pid_path if File::exist? config.daemon_full_pid_path else acase = {:case => :not_found, :more => "Splash is not running"} end return acase end @@ -102,10 +102,10 @@ # @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) + pid = `cat #{config.daemon_full_pid_path}`.to_s if File.exist?(config.daemon_full_pid_path) listpid = get_processes({ :pattern => get_config.daemon_process_name}) pid.chomp! if listpid.empty? then realpid = '' else