Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 66 lines (55 sloc) 1.844 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 59 60 61 62 63 64 65 66
include_recipe "joy_of_cooking::daemontools"
include_recipe "joy_of_cooking::mysql"

app_user = "mkocher"

execute "trust github" do
  command "mkdir -p ~/.ssh/ && echo 'github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' > ~/.ssh/known_hosts"
  user app_user
end

execute "user owns app dir" do
  command "chown -R #{app_user} #{ENV['APP_DIR']}"
end

execute "git clone" do
  command "git clone git://github.com/mkocher/chef_deploy.git src"
  cwd ENV['APP_DIR']
  not_if { File.exists?("#{ENV['APP_DIR']}/src/.git/")}
  user app_user
end

execute "checkout HEAD" do
  command "git reset HEAD --hard && git pull"
  cwd "#{ENV['APP_DIR']}/src"
  user app_user
end

execute "bundle" do
  command "bundle"
  user app_user
  cwd "#{ENV['APP_DIR']}/src"
end

execute "create db" do
  command "bundle exec rake db:create"
  user app_user
  environment 'RACK_ENV' => 'staging'
  cwd "#{ENV['APP_DIR']}/src"
end

execute "rake db:migrate" do
  command "bundle exec rake db:migrate"
  user app_user
  environment 'RACK_ENV' => 'staging'
  cwd "#{ENV['APP_DIR']}/src"
end

execute "create daemontools directory" do
  command "mkdir -p /service/unicorn"
end

file "/service/unicorn/run" do
  content %{#!/bin/bash
cd /var/staging/foo/src
rvm_path=/home/mkocher/.rvm/
export RAILS_ENV=staging
source /home/mkocher/.rvm/scripts/rvm
rvm use ruby-1.8.7-p299@captest
exec /command/setuidgid mkocher unicorn -p 3000
}
  mode "0755"
end

execute "restart unicorn" do
  command "svc -k /service/unicorn"
end
Something went wrong with that request. Please try again.