Class: OAR::Scripting::Application

Inherits:
Object
  • Object
show all
Includes:
Mixlib::CLI
Defined in:
lib/oar/scripting/application.rb

Direct Known Subclasses

Graph

Defined Under Namespace

Classes: Graph

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/oar/scripting/application.rb', line 12

def initialize
  super

  trap("TERM") do
    OAR::Scripting::Application.fatal!("SIGTERM received, stopping", 1)
  end

  trap("INT") do
    OAR::Scripting::Application.fatal!("SIGINT received, stopping", 2)
  end
end

Class Method Details

.exit!(msg, err = -1)) ⇒ Object

Definition

fatal!(msg, err = -1)



42
43
44
# File 'lib/oar/scripting/application.rb', line 42

def exit!(msg, err = -1)
  Process.exit err
end

.fatal!(msg, err = -1)) ⇒ Object



37
38
39
40
# File 'lib/oar/scripting/application.rb', line 37

def fatal!(msg, err = -1)
  STDERR.puts("FATAL: #{msg}")
  Process.exit err
end

Instance Method Details

#runObject

Definition

initialize



24
25
26
27
28
29
30
# File 'lib/oar/scripting/application.rb', line 24

def run
  # use parse_options from Mixlib
  parse_options

  # Run application
  run_application
end

#run_applicationObject

Definition

run



32
33
34
# File 'lib/oar/scripting/application.rb', line 32

def run_application
  raise "#{self.to_s}: you must override run_application"
end