Class: Kaiser::Service
- Inherits:
-
Object
- Object
- Kaiser::Service
- Defined in:
- lib/kaiser/service.rb
Overview
This class describes an app-specific service
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #binds ⇒ Object
- #command ⇒ Object
- #env ⇒ Object
- #image ⇒ Object
-
#initialize(envname, name, service_info) ⇒ Service
constructor
A new instance of Service.
- #shared_name ⇒ Object
- #start_docker_command ⇒ Object
Constructor Details
#initialize(envname, name, service_info) ⇒ Service
Returns a new instance of Service.
8 9 10 11 12 |
# File 'lib/kaiser/service.rb', line 8 def initialize(envname, name, service_info) @envname = envname @name = name @service_info = service_info end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/kaiser/service.rb', line 6 def name @name end |
Instance Method Details
#binds ⇒ Object
26 27 28 |
# File 'lib/kaiser/service.rb', line 26 def binds @service_info[:binds] || {} end |
#command ⇒ Object
22 23 24 |
# File 'lib/kaiser/service.rb', line 22 def command @service_info[:command].to_s end |
#env ⇒ Object
30 31 32 |
# File 'lib/kaiser/service.rb', line 30 def env @service_info[:env] || {} end |
#image ⇒ Object
18 19 20 |
# File 'lib/kaiser/service.rb', line 18 def image @service_info[:image] end |
#shared_name ⇒ Object
14 15 16 |
# File 'lib/kaiser/service.rb', line 14 def shared_name "#{@envname}-#{name}" end |
#start_docker_command ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kaiser/service.rb', line 34 def start_docker_command envstring = env.map do |k, v| "-e #{k}=#{v}" end.join(' ') bindstring = binds.map do |k, v| "-v #{k}:#{v}" end.join(' ') commandstring = command cmd_array = [ 'docker run -d', "--name #{shared_name}", "--network #{Config.config[:networkname]}", envstring, bindstring, image, commandstring ] cmd_array.filter! { |x| !x.empty? } cmd_array.join(' ') end |