class Alphonse::Operator

Attributes

config[R]

Public Class Methods

new(config = {}) click to toggle source
# File lib/alphonse/operator.rb, line 11
def initialize(config = {})
  @config = config
end

Public Instance Methods

execute(command) click to toggle source
# File lib/alphonse/operator.rb, line 15
def execute(command)
  hosts.each do |host_connection|
    begin
      Alphonse.logger.info "\e[4mRunning on #{host_connection.connection_string}\e[0m"
      
      host_connection.send_and_execute send(command)

      Alphonse.logger.success "Aaaaaay! All Actions Completed"
    rescue Exception => e
      Alphonse.logger.error "#{e.class.to_s} : #{e.message}\n\n#{e.backtrace.join("\n")}"
      break
    ensure
      host_connection.close
    end
  end
end

Private Instance Methods

bundle_update() click to toggle source

Issue bundle command on remote server

# File lib/alphonse/operator.rb, line 47
def bundle_update
  Alphonse.logger.operation config[:bundle_description]
  prerequisite.push config[:bundle_update].map { |task| send(task) }
end
deploy() click to toggle source

First time deploy of app to remote server

# File lib/alphonse/operator.rb, line 41
def deploy
  Alphonse.logger.operation config[:deploy_description]
  prerequisite.push config[:deploy].map { |task| send(task) }
end
hosts() click to toggle source
# File lib/alphonse/operator.rb, line 72
def hosts
  @hosts ||= begin
    host_connections, hosts, user = [], (config[:hosts] rescue nil), (config[:user] rescue nil)
    hosts.each {|host| host_connections << Connection.new(host, user, config) } if hosts && user; 
    host_connections
  end
end
prerequisite() click to toggle source
# File lib/alphonse/operator.rb, line 68
def prerequisite
  [cd_to_path]
end
restart() click to toggle source

Restart the app

# File lib/alphonse/operator.rb, line 59
def restart
  Alphonse.logger.operation config[:restart_description]
  prerequisite.push config[:restart].map { |task| send(task) }
end
setup() click to toggle source

Create and setup folder on remote server

# File lib/alphonse/operator.rb, line 35
def setup
  Alphonse.logger.operation config[:setup_description]
  setup_prerequisite.push config[:setup].map { |task| send task }
end
setup_prerequisite() click to toggle source
# File lib/alphonse/operator.rb, line 64
def setup_prerequisite
  [cd_to_parent_path]
end
update() click to toggle source

Pull latest on remote server

# File lib/alphonse/operator.rb, line 53
def update
  Alphonse.logger.operation config[:update_description]
  prerequisite.push config[:update].map { |task| send(task) }
end