Module: Xn::DeployUtils

Defined in:
lib/xnlogic/deploy.rb

Class Method Summary collapse

Class Method Details

.deploy(options = {}, &post_stage_proc) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/xnlogic/deploy.rb', line 59

def deploy(options = {}, &post_stage_proc)
  if !ENV.key?('CONFIG_FILE')
    fail 'CONFIG_FILE environment variable required'
  elsif !File.exists?(ENV['CONFIG_FILE'])
    fail "No configuration file found at #{ENV['CONFIG_FILE']}"
  end

  puts "Creating application knob with options #{ options.inspect }"
  path = TorqueBox::DeployUtils.create_archive options
  puts "Archive created: #{path} size: #{File.size(path)}"
  archive_name = TorqueBox::DeployUtils.archive_name
  puts 'Deploying to staging area...'
  puts "  #{ archive_name }"
  TorqueBox::RemoteDeployUtils.stage(archive_name)

  # Give calling Rake task an opportunity to do whatever extra work is required.
  post_stage_proc.call archive_name if post_stage_proc

  puts "Application has been uploaded to /opt/torquebox/current/stage/#{archive_name}"
  puts 'Deployment paused to give you the opportunity to log in and run any necessary rake tasks'
  puts 'Press enter to continue...'
  STDIN.gets

  TorqueBox::RemoteDeployUtils.deploy_from_stage(archive_name)
  TorqueBox::RemoteDeployUtils.change_yml_permissions(archive_name)

  puts 'Deployed!'
end