Class: Shipper::Host
- Inherits:
-
Object
- Object
- Shipper::Host
- Defined in:
- lib/shipper/host.rb
Instance Attribute Summary collapse
-
#executor ⇒ Object
Returns the value of attribute executor.
-
#host ⇒ Object
Returns the value of attribute host.
-
#location ⇒ Object
Returns the value of attribute location.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(options) ⇒ Host
constructor
A new instance of Host.
- #restart!(pull_changes: false) ⇒ Object
- #update! ⇒ Object
Constructor Details
#initialize(options) ⇒ Host
Returns a new instance of Host.
7 8 9 10 11 12 13 14 |
# File 'lib/shipper/host.rb', line 7 def initialize() @user, full_host = ['ssh_entry'].split('@') @host, @port = full_host.split(':') @port = @port || 22 @location = ['location'] @executor = nil end |
Instance Attribute Details
#executor ⇒ Object
Returns the value of attribute executor.
5 6 7 |
# File 'lib/shipper/host.rb', line 5 def executor @executor end |
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/shipper/host.rb', line 5 def host @host end |
#location ⇒ Object
Returns the value of attribute location.
5 6 7 |
# File 'lib/shipper/host.rb', line 5 def location @location end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/shipper/host.rb', line 5 def port @port end |
#user ⇒ Object
Returns the value of attribute user.
5 6 7 |
# File 'lib/shipper/host.rb', line 5 def user @user end |
Instance Method Details
#restart!(pull_changes: false) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# 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! ⇒ Object
16 17 18 |
# File 'lib/shipper/host.rb', line 16 def update! restart!(pull_changes: true) end |