Class: Kuroko2::Workflow::Task::Execute

Inherits:
Base
  • Object
show all
Defined in:
lib/autoload/kuroko2/workflow/task/execute.rb

Direct Known Subclasses

KurokoRunner

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Kuroko2::Workflow::Task::Base

Instance Method Details

#before_executeObject



24
25
# File 'lib/autoload/kuroko2/workflow/task/execute.rb', line 24

def before_execute
end

#chdirObject



27
28
29
# File 'lib/autoload/kuroko2/workflow/task/execute.rb', line 27

def chdir
  nil
end

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/autoload/kuroko2/workflow/task/execute.rb', line 5

def execute
  if (execution = Execution.of(token).take)
    update_execution(execution)
  else
    validate

    token.context['CHDIR'] = chdir
    before_execute

    Execution.create!(token:          token,
      job_definition: token.job_definition,
      job_instance:   token.job_instance,
      shell:          shell,
      queue:          token.context['QUEUE'] || Execution::DEFAULT_QUEUE,
      context:        token.context)
    :pass
  end
end

#shellObject



31
32
33
# File 'lib/autoload/kuroko2/workflow/task/execute.rb', line 31

def shell
  option
end

#validateObject



35
36
37
38
39
# File 'lib/autoload/kuroko2/workflow/task/execute.rb', line 35

def validate
  if option.blank?
    raise Workflow::AssertionError, "Option is required for execute"
  end
end