Class: Commands::Run

Inherits:
Object
  • Object
show all
Defined in:
lib/app-runner/commands/run.rb

Instance Method Summary collapse

Instance Method Details

#execute(global_options, options, args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/app-runner/commands/run.rb', line 5

def execute(global_options, options, args)
  config=global_options['configHash'];
  if (!args.empty?)
    options["url"]=args.first
    args.clear
    Commands::Switch.new().execute(global_options, options, args)
  end
  exec=options["exec"]
  exec=config['exec'] if !exec
  app_pid=spawn(exec)
  [ :INT, :TERM, :HUP  ].each do |sig|
    Signal.trap(sig) { signal(sig, app_pid) }
  end
  Process.wait(app_pid)

end

#signal(sig, pid) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/app-runner/commands/run.rb', line 22

def signal(sig, pid)
  begin
    Process.kill(sig, pid)
  rescue Errno::ESRCH
    false
  end
end