Class: SiblingDeployer

Inherits:
Object
  • Object
show all
Extended by:
HerokuResqueAutoscaler
Defined in:
app/workers/sibling_deployer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_id) ⇒ SiblingDeployer

Returns a new instance of SiblingDeployer.



10
11
12
13
# File 'app/workers/sibling_deployer.rb', line 10

def initialize(app_id)
  @app = Sibling::Deploy.find(app_id)
  @retries = 0
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



4
5
6
# File 'app/workers/sibling_deployer.rb', line 4

def app
  @app
end

#retriesObject (readonly)

Returns the value of attribute retries.



4
5
6
# File 'app/workers/sibling_deployer.rb', line 4

def retries
  @retries
end

Class Method Details

.perform(app_id) ⇒ Object



6
7
8
# File 'app/workers/sibling_deployer.rb', line 6

def self.perform(app_id)
  self.new(app_id).perform
end

Instance Method Details

#increment_retriesObject



37
38
39
# File 'app/workers/sibling_deployer.rb', line 37

def increment_retries
  @retries += 1
end

#performObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/workers/sibling_deployer.rb', line 15

def perform
  Rails.logger.info "Starting deploying sibling..."
  @app.deploy
  Rails.logger.info "Succeeded deploying sibling."
rescue GithubHerokuDeployer::CommandException,
       Heroku::API::Errors::ErrorWithResponse => e
  if should_retry?
    Rails.logger.info "Retrying deploying sibling..."
    increment_retries
    retry
  else
    raise e
  end
rescue StandardError => e
  Rails.logger.info "Failed deploying sibling."
  raise e
end

#should_retry?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/workers/sibling_deployer.rb', line 33

def should_retry?
  @retries < 3
end