Module: RailsDeployer::Bring

Includes:
Common
Included in:
Rake
Defined in:
lib/rails_deployer/bring.rb

Overview

Operations specific to the Bring operational environment

Defined Under Namespace

Modules: Rake

Constant Summary

Constants included from Common

Common::BUNDLE, Common::RAKE, Common::RBENV

Instance Method Summary collapse

Methods included from Common

#cd_to_local, #checkout, #get_name, #install_bundle, #migrate, #precompile_assets, #restart, #restart_queue, #restart_websocket, #say, #seed, #set_env, #set_precompile_relative_url, #set_proxy, #update_crontab, #upload

Instance Method Details

#change_branch(env) ⇒ Object



8
9
10
11
12
13
# File 'lib/rails_deployer/bring.rb', line 8

def change_branch(env)
  Net::SSH.start(env[:host], env[:user]) do |ssh|
    say "Checking out the branch we are deploying: #{env[:branch]}"
    ssh.exec("cd #{env[:remote_path]} && git checkout #{env[:branch]}")
  end
end

#deploy(app_name, rails_env) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rails_deployer/bring.rb', line 32

def deploy(app_name, rails_env)
  env = make_env(app_name, rails_env)
  pp env
  upload(env)
  change_branch(env)
  install_bundle(env)
  precompile_assets(env)
  migrate(env)
  seed(env, :seed => (ENV['seed'] == 'true'))
  restart(env)
end

#make_env(app_name, rails_env) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails_deployer/bring.rb', line 15

def make_env(app_name, rails_env)
  branch = ENV['branch'] || 'master'
  suffix = ("_#{rails_env}" if rails_env != 'production')
  user = 'posten'
  host = rails_env == 'production' ? 'posap408.unix.cosng.net' : 'posap413.unix.cosng.net'
  {
      branch: branch,
      host: host,
      http_proxy: 'http://proxy.ergogroup.no:3128',
      push_to_repo: "#{user}@#{host}:/var/apps/#{app_name}#{suffix}/.git",
      rails_env: rails_env,
      remote_path: "/var/apps/#{app_name}#{suffix}",
      user: user,
      wheneverize: true,
  }
end