Module: Deployman::App

Defined in:
lib/deployman/app.rb

Defined Under Namespace

Modules: Configuration, Install, Optionparser, Postsetup

Class Method Summary collapse

Class Method Details

.run(args = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/deployman/app.rb', line 3

def self.run (args = nil)
  args ||= ARGV.dup.map! { |v| v.dup }

  # parse all options of command-line
  options = Deployman::App::Optionparser.parse args

  if options[:callback]

    # redirect output (stdout, stderr) to tempfiles
    Deployman::Component::Output.redirect_output

    # deactivate spinningclock for clear output
    Deployman::Component::Spinningclock.set_active false

    begin
      # call <Application> (e.g. http://localhost:8000/callback/install)
      Deployman::Net::Post.send options[:callback], { "status" => "running", "stdout" => nil, "stderr" => nil }
      # run deploy with parsed options
      Deployman::App::Install.run options
      # call <Application>
      Deployman::Net::Post.send options[:callback], { "status" => "finished", "stdout" => Deployman::Component::Output.get_stdout, "stderr" => Deployman::Component::Output.get_stderr }
    rescue Exception => e
          warn "ERROR: #{e.message}"
          # call <Application>
      Deployman::Net::Post.send options[:callback], { "status" => "error", "stdout" => Deployman::Component::Output.get_stdout, "stderr" => Deployman::Component::Output.get_stderr }
      end

  else 
    begin
      # run deploy with parsed options
      Deployman::App::Install.run options
    rescue Exception => e
          warn "ERROR: #{e.message}"
      end  
  end
end