Class: Mutx::Execution

Inherits:
Object
  • Object
show all
Defined in:
lib/mutx/execution.rb

Class Method Summary collapse

Class Method Details

.attachment_pathObject



22
23
24
25
26
27
# File 'lib/mutx/execution.rb', line 22

def self.attachment_path
  str = ARGV.select{|arg| arg.start_with? "_id="}.first
  raise "Could not find execution id" if str.nil?
  id = str.split("=").last
  "#{Dir.pwd}/mutx/out/#{id}/attachment"
end

.run!(execution_request_data) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mutx/execution.rb', line 5

def self.run! execution_request_data

    Mutx::Support::Log.debug "Execution Request Data => #{execution_request_data}" if Mutx::Support::Log
    result = Mutx::Results::Result.new(execution_request_data)
    Mutx::Support::Log.debug "Result created with id => #{result.id}" if Mutx::Support::Log

    Dir.mkdir "#{Dir.pwd}/mutx/out" unless Dir.exist? "#{Dir.pwd}/mutx/out"
    Dir.mkdir "#{Dir.pwd}/mutx/out/#{result.id}/attachment"

    result.save!

    Mutx::Support::Log.debug "Execution type #{result.task_type}" if Mutx::Support::Log
    Mutx::Workers::Executor.perform_async(result.id)
    Mutx::Support::Log.debug "#{result.task_type.capitalize}(#{result.id}) started" if Mutx::Support::Log
    result.id
end