lib/splash/daemon/orchestrator.rb in prometheus-splash-0.6.0 vs lib/splash/daemon/orchestrator.rb in prometheus-splash-0.6.1
- old
+ new
@@ -19,10 +19,11 @@
include Splash::Daemon::Orchestrator::Grammar
include Splash::Loggers
include Splash::Logs
include Splash::Processes
include Splash::Commands
+ include Splash::Sequences
# Constructor prepare the Scheduler
# commands Schedules
# logs monitorings
# process monitorings
@@ -40,10 +41,11 @@
@log.info "Splash Orchestrator starting :"
if options[:scheduling] then
@log.item "Initializing commands Scheduling."
init_commands_scheduling
+ init_sequences_scheduling
end
if @config.logs.empty? then
@log.item "No logs to monitor"
else
@@ -138,17 +140,36 @@
end
end
end
+
+ # prepare sequences Scheduling
+ def init_sequences_scheduling
+ config = get_config.sequences
+ sequences = config.select{|key,value| value.include? :schedule}.keys
+ sequences.each do |sequence|
+ sched,value = config[sequence][:schedule].flatten
+ @log.arrow "Scheduling sequence #{sequence.to_s}"
+ @server.send sched,value do
+ session = get_session
+ @log.trigger "Executing Scheduled sequence #{sequence.to_s} for Scheduling : #{sched.to_s} #{value.to_s}", session
+ run_seq name: sequence.to_s, session: session
+ 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
+ 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