Module: ORS::Helpers::CommandHelpers

Included in:
ORS::Helpers
Defined in:
lib/ors/helpers.rb

Overview

Helpers for commands for re-use

Instance Method Summary collapse

Instance Method Details

#bundle_install(server) ⇒ Object



79
80
81
82
83
84
# File 'lib/ors/helpers.rb', line 79

def bundle_install server
  info "[#{server}] installing bundle..."

  execute_command server, prepare_environment_with_rvm,
  %(bundle install --without development test osx_development > bundler.log)
end

#restart_server(server) ⇒ Object



100
101
102
103
104
105
# File 'lib/ors/helpers.rb', line 100

def restart_server server
  info "[#{server}] restarting unicorn..."

  execute_command server, prepare_environment,
  %(kill -USR2 \\`cat tmp/pids/unicorn.pid\\`)
end

#run_migrations(server) ⇒ Object



107
108
109
110
111
112
# File 'lib/ors/helpers.rb', line 107

def run_migrations server
  info "[#{server}] running migrations..."

  execute_command server, prepare_environment_with_rvm,
  %(RAILS_ENV=#{ORS.config[:environment]} bundle exec rake db:migrate db:seed)
end

#setup_repo(server) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/ors/helpers.rb', line 49

def setup_repo server
  info "[#{server}] installing codebase..."

  execute_command server, %(cd #{ORS.config[:base_path]}),
  %(rm -rf #{ORS.config[:deploy_directory]}),
  %(git clone #{ORS.config[:remote_url]} #{ORS.config[:deploy_directory]}),
  %(mkdir -p #{ORS.config[:deploy_directory]}/tmp/pids),
  %(mkdir -p #{ORS.config[:deploy_directory]}/log)
end

#setup_ruby(server) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/ors/helpers.rb', line 59

def setup_ruby server
  info "[#{server}] installing ruby and gems..."

  execute_command server, prepare_initial_environment,
  %(gem install rubygems-update),
  %(gem update --system),
  %(gem install bundler),
  %(bundle install --without development test osx_development > bundler.log)
end

#start_server(server) ⇒ Object



86
87
88
89
90
91
# File 'lib/ors/helpers.rb', line 86

def start_server server
  info "[#{server}] starting unicorn..."

  execute_command server, prepare_environment_with_rvm,
  %(if [ -f config.ru ]; then RAILS_ENV=#{ORS.config[:environment]} bundle exec unicorn -c config/unicorn.rb -D; else RAILS_ENV=#{ORS.config[:environment]} bundle exec unicorn_rails -c config/unicorn.rb -D; fi)
end

#stop_server(server) ⇒ Object



93
94
95
96
97
98
# File 'lib/ors/helpers.rb', line 93

def stop_server server
  info "[#{server}] stopping unicorn..."

  execute_command server, prepare_environment,
  %(kill \\`cat tmp/pids/unicorn.pid\\`)
end

#update_code(server) ⇒ Object



69
70
71
72
73
74
75
76
77
# File 'lib/ors/helpers.rb', line 69

def update_code server
  info "[#{server}] updating codebase..."

  execute_command server, prepare_environment,
  %(git fetch #{ORS.config[:remote]}),
  %(git checkout -q -f #{ORS.config[:remote]}/#{ORS.config[:branch]}),
  %(git reset --hard),
  %(git submodule update --init)
end