Class: HR_Deploy::OpenAppTask

Inherits:
Task
  • Object
show all
Defined in:
lib/hr_deploy/tasks/open_app_task.rb

Constant Summary collapse

ONE_TRY_TIME =
5
TOTAL_TRY_TIME =
60

Instance Attribute Summary

Attributes inherited from Task

#end_time, #error, #start_time

Instance Method Summary collapse

Methods inherited from Task

#initialize, #reversal_instruction, #successful?

Constructor Details

This class inherits a constructor from HR_Deploy::Task

Instance Method Details

#runObject



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
39
# File 'lib/hr_deploy/tasks/open_app_task.rb', line 12

def run
  print_stage 'Opening app...'
  open_command = "heroku open --remote #{target.name}"

  if dry_run?
    execute_system_command(open_command)
    self.success = true
    return
  end

  ending_time = Time.now + HR_Deploy::OpenAppTask::TOTAL_TRY_TIME

  until success == true || success == false
    status = try_status

    if status == :ok
      execute_system_command(open_command)
      set_end_time
      self.success = true

    elsif status == :fail || (status == :retry && Time.now > ending_time)

      self.success = false
      self.error = "Could not open app\n" +
          "To open manually: #{open_command}"
    end
  end
end