class Shipper::Host

Attributes

executor[RW]
host[RW]
location[RW]
port[RW]
user[RW]

Public Class Methods

new(options) click to toggle source
# File lib/shipper/host.rb, line 7
def initialize(options)
  @user, full_host = options['ssh_entry'].split('@')
  @host, @port = full_host.split(':')
  @port = @port || 22

  @location = options['location']
  @executor = nil
end

Public Instance Methods

restart!(pull_changes: false) click to toggle source
# File lib/shipper/host.rb, line 20
def restart!(pull_changes: false)
  ::Net::SSH.start(host, user, port: port) do |ssh|
    load_executor(ssh)
    executor.cd location
    exec 'docker-compose pull' if pull_changes
    exec 'docker-compose down'
    exec 'docker-compose up -d'
  end
end
update!() click to toggle source
# File lib/shipper/host.rb, line 16
def update!
  restart!(pull_changes: true)
end

Private Instance Methods

exec(cmd) click to toggle source
# File lib/shipper/host.rb, line 32
def exec(cmd)
  executor.exec(cmd)
end
load_executor(ssh) click to toggle source
# File lib/shipper/host.rb, line 36
def load_executor(ssh)
  @executor = ::Shipper::Executor.new(ssh, location)
end