Sha256: 88298e83526750c4d3b33c3d7c508294a6baf2fbdf6da078baa8d35fdc3d5503

Contents?: true

Size: 925 Bytes

Versions: 19

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

require_relative './executor.rb'

module Fusuma
  module Plugin
    module Executors
      # Exector plugin
      class CommandExecutor < Executor
        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

        def executable?(event)
          event.tag.end_with?('_detector') &&
            event.record.type == :index &&
            search_command(event)
        end

        # @param event [Event]
        # @return [String]
        def search_command(event)
          command_index = Config::Index.new([*event.record.index.keys, :command])
          Config.search(command_index)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
fusuma-1.11.1 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.10.2 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.10.1 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.10.0 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.9.0 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.8.0 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.7.0 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.6.0 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.5.0 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.4.1 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.4.0 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.3.3 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.3.2 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.3.1 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.3.0 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.2.1 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.2 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.1 lib/fusuma/plugin/executors/command_executor.rb
fusuma-1.0 lib/fusuma/plugin/executors/command_executor.rb