lib/splash/daemon/orchestrator.rb in prometheus-splash-0.5.3 vs lib/splash/daemon/orchestrator.rb in prometheus-splash-0.6.0
- old
+ new
@@ -1,12 +1,18 @@
# coding: utf-8
Dir[File.dirname(__FILE__) + '/orchestrator/*.rb'].each {|file| require file }
+# base Splash module
module Splash
+
+ # global daemon module
module Daemon
+
+ # orchestrator specific module
module Orchestrator
+ # Splash Scheduler object
class Scheduler
include Splash::Constants
include Splash::Helpers
include Splash::Config
include Splash::Transports
@@ -14,11 +20,16 @@
include Splash::Loggers
include Splash::Logs
include Splash::Processes
include Splash::Commands
-
+ # Constructor prepare the Scheduler
+ # commands Schedules
+ # logs monitorings
+ # process monitorings
+ # @param [Hash] options
+ # @option options [Symbol] :scheduling activate commands scheduling
def initialize(options = {})
@log = get_logger
self.extend Splash::Daemon::Metrics
@metric_manager = get_metrics_manager
$stdout.sync = true
@@ -101,18 +112,21 @@
get_default_client.publish queue: content[:return_to], message: "Unkown verb #{content[:verb]}".to_yaml
end
end
end
+ # Stop the Splash daemon gracefully
+ # @return [hash] Exiter Case :quiet_exit
def terminate
@log.info "Splash daemon shutdown"
@server.shutdown
change_logger logger: :cli
splash_exit case: :quiet_exit
end
private
+ # prepare commands Scheduling
def init_commands_scheduling
config = get_config.commands
commands = config.select{|key,value| value.include? :schedule}.keys
commands.each do |command|
sched,value = config[command][:schedule].flatten
@@ -124,13 +138,17 @@
end
end
end
+ # execute_command verb : execute command specified in payload
+ # @param [Hash] options
+ # @option options [Symbol] :command the name of the command
+ # @option options [Symbol] :ack ack flag to inhibit execution and send ack to Prometheus (0)
+ # @return [Hash] Exiter case
def execute(options)
command = CommandWrapper::new(options[:command])
- if options[:ack] then
- command.ack
+ if options[:ack] then
else
@metric_manager.inc_execution
return command.call_and_notify trace: true, notify: true, callback: true, session: options[:session]
end
end