Class: Servitor::EnvdirDeployer
- Inherits:
-
Object
- Object
- Servitor::EnvdirDeployer
- Includes:
- ChildProcessHelper
- Defined in:
- lib/deployment/envdir_deployer.rb
Instance Attribute Summary collapse
-
#box ⇒ Object
readonly
Returns the value of attribute box.
-
#dirname ⇒ Object
readonly
Returns the value of attribute dirname.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
- #deploy ⇒ Object
-
#initialize(box, service_name, path, dirname, variables) ⇒ EnvdirDeployer
constructor
A new instance of EnvdirDeployer.
Methods included from ChildProcessHelper
#execute_child_process, #execute_child_process_and_capture_output, included
Constructor Details
#initialize(box, service_name, path, dirname, variables) ⇒ EnvdirDeployer
Returns a new instance of EnvdirDeployer.
7 8 9 10 11 12 13 |
# File 'lib/deployment/envdir_deployer.rb', line 7 def initialize(box, service_name, path, dirname, variables) @service_name = service_name @box = box @path = path @dirname = dirname @variables = variables end |
Instance Attribute Details
#box ⇒ Object (readonly)
Returns the value of attribute box.
5 6 7 |
# File 'lib/deployment/envdir_deployer.rb', line 5 def box @box end |
#dirname ⇒ Object (readonly)
Returns the value of attribute dirname.
5 6 7 |
# File 'lib/deployment/envdir_deployer.rb', line 5 def dirname @dirname end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/deployment/envdir_deployer.rb', line 5 def path @path end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
5 6 7 |
# File 'lib/deployment/envdir_deployer.rb', line 5 def variables @variables end |
Instance Method Details
#deploy ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/deployment/envdir_deployer.rb', line 15 def deploy # envdir is part of daemontools box.ssh('which envdir || sudo apt-get install daemontools', :vm_name => @service_name, :ignore_exit_code => true, :capture => true) box.ruby(<<-RUBY, :vm_name => @service_name, :sudo => true) require 'fileutils' envdir = File.join(#{path.inspect}, #{dirname.inspect}) variables = #{variables.inspect} FileUtils.rm_rf(envdir) FileUtils.mkdir_p(envdir) Dir.chdir(envdir) do variables.each do |name, value| File.open(name.upcase, 'w') {|f| f.write(value.gsub("\n", 0.chr)) } if value end end RUBY end |