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

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

Direct Known Subclasses

KurokoRunner

Constant Summary collapse

DEFAULT_EXPECTED_TIME =

24 hours

60 * 24
EXPECTED_TIME_NOTIFY_REMIND_TERM =
1.hours

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



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

def before_execute
end

#chdirObject



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

def chdir
  nil
end

#executeObject



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

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



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

def shell
  option
end

#validateObject



38
39
40
41
42
# File 'lib/autoload/kuroko2/workflow/task/execute.rb', line 38

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