Class: Fusuma::Plugin::Executors::CommandExecutor
- Inherits:
-
Executor
- Object
- Base
- Executor
- Fusuma::Plugin::Executors::CommandExecutor
show all
- Defined in:
- lib/fusuma/plugin/executors/command_executor.rb
Overview
Instance Method Summary
collapse
Methods inherited from Base
#config_index, #config_param_types, #config_params, inherited, plugins
Instance Method Details
#executable?(event) ⇒ Boolean
24
25
26
27
28
|
# File 'lib/fusuma/plugin/executors/command_executor.rb', line 24
def executable?(event)
event.tag.end_with?('_detector') &&
event.record.type == :index &&
search_command(event)
end
|
#execute(event) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/fusuma/plugin/executors/command_executor.rb', line 10
def execute(event)
search_command(event).tap do |command|
break unless command
MultiLogger.info(command: command)
pid = fork do
Process.daemon(true)
exec(command.to_s)
end
Process.detach(pid)
end
end
|
#search_command(event) ⇒ String
32
33
34
35
|
# File 'lib/fusuma/plugin/executors/command_executor.rb', line 32
def search_command(event)
command_index = Config::Index.new([*event.record.index.keys, :command])
Config.search(command_index)
end
|