Class: Naf::ApplicationType

Inherits:
NafBase
  • Object
show all
Defined in:
app/models/naf/application_type.rb

Constant Summary collapse

SCRIPT_RUNNER =
"#{Gem.ruby} #{Rails.root}/script/rails runner"
JOB_LOGGER =
"#{Rails.root}/script/rails runner ::Process::Naf::Logger::JobLog.run"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NafBase

full_table_name_prefix

Class Method Details

.bash_commandObject



65
66
67
# File 'app/models/naf/application_type.rb', line 65

def self.bash_command
  @bash_command ||= find_by_script_type_name('bash command')
end

.bash_scriptObject



69
70
71
# File 'app/models/naf/application_type.rb', line 69

def self.bash_script
  @bash_script ||= find_by_script_type_name('bash script')
end

.railsObject



57
58
59
# File 'app/models/naf/application_type.rb', line 57

def self.rails
  @rails ||= find_by_script_type_name('rails')
end

.rubyObject



61
62
63
# File 'app/models/naf/application_type.rb', line 61

def self.ruby
  @ruby ||= find_by_script_type_name('ruby')
end

Instance Method Details

#bash_command_invocator(job) ⇒ Object



45
46
47
# File 'app/models/naf/application_type.rb', line 45

def bash_command_invocator(job)
  invoke(job, job.command)
end

#bash_script_invocator(job) ⇒ Object



49
50
51
# File 'app/models/naf/application_type.rb', line 49

def bash_script_invocator(job)
  invoke(job, job.command)
end

#invoke(job, job_command) ⇒ Object



36
37
38
39
# File 'app/models/naf/application_type.rb', line 36

def invoke(job, job_command)
  command = job_command + " 2>&1 | #{JOB_LOGGER} >> #{LOGGING_ROOT_DIRECTORY}/naf/crash.log 2>&1"
  Process.spawn({ 'NAF_JOB_ID' => job.id.to_s }, command)
end

#rails_invocator(job) ⇒ Object



41
42
43
# File 'app/models/naf/application_type.rb', line 41

def rails_invocator(job)
  invoke(job, SCRIPT_RUNNER + " " + job.command)
end

#ruby_script_invocator(job) ⇒ Object



53
54
55
# File 'app/models/naf/application_type.rb', line 53

def ruby_script_invocator(job)
  invoke(job, job.command)
end

#spawn(job) ⇒ Object


*** Instance Methods *** +++++++++++++++++++++++++



32
33
34
# File 'app/models/naf/application_type.rb', line 32

def spawn(job)
  self.send(invocation_method.to_sym, job)
end