Permalink
Browse files

sinatra working

  • Loading branch information...
mkocher committed Apr 5, 2011
1 parent a863efc commit 8b4efad8faead8e8ef3d9700969cbaac42f69296
Showing with 67 additions and 4 deletions.
  1. +3 −2 Capfile
  2. +55 −0 chef/cookbooks/joy_of_cooking/recipes/application.rb
  3. +1 −1 config/deploy/staging.rb
  4. +8 −1 soloistrc
View
@@ -2,7 +2,7 @@ require 'capistrano/ext/multistage'
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
-set :rvm_ruby_string, 'ruby-1.8.7-p299@testgemset' # Or whatever env you want it to run in.
+set :rvm_ruby_string, 'ruby-1.8.7-p299@captest' # Or whatever env you want it to run in.
set :rvm_type, :user
set :app_name, :foo
@@ -20,6 +20,7 @@ end
desc "Install gems that are needed for a chef run"
task :install_base_gems do
run "gem list | grep soloist || gem install soloist --no-rdoc --no-ri"
+ run "gem list | grep bundler || gem install bundler --no-rdoc --no-ri"
# run "gem list | grep hellspawn || gem install hellspawn --no-rdoc --no-ri"
end
@@ -35,7 +36,7 @@ end
desc "Run Chef"
task :run_chef do
- run "cd #{app_dir} && PATH=/usr/sbin:$PATH soloist"
+ run "cd #{app_dir} && PATH=/usr/sbin:$PATH APP_NAME=#{fetch(:app_name)} APP_DIR=#{fetch(:app_dir)} soloist"
end
desc "bootstrap"
@@ -0,0 +1,55 @@
+# execute "make src directory" do
+# dir_name = "#{ENV["APP_DIR"]}"
+# command "mkdir -p #{dir_name}"
+# not_if { File.exists?(dir_name) }
+# end
+#
+
+include_recipe "joy_of_cooking::daemontools"
+
+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 daemontools directory" do
+ command "mkdir -p /service/appserver"
+end
+
+file "/service/appserver/run" do
+ content %{#!/bin/bash
+cd /var/staging/foo/src
+rvm_path=/home/mkocher/.rvm/
+source /home/mkocher/.rvm/scripts/rvm
+rvm use ruby-1.8.7-p299@captest
+exec /command/setuidgid mkocher rackup -p 4567
+}
+ mode "0755"
+ # not_if "ls /service/appserver/run"
+end
View
@@ -1,3 +1,3 @@
-role :app, "ec2-184-73-47-68.compute-1.amazonaws.com"
+role :app, "ec2-50-17-159-176.compute-1.amazonaws.com"
View
@@ -1,4 +1,11 @@
cookbook_paths:
- ./chef/cookbooks/
recipes:
-- joy_of_cooking::mysql
+- joy_of_cooking::application
+env_variable_switches:
+ APP_NAME:
+ cookbook_paths: []
+ recipes: []
+ APP_DIR:
+ cookbook_paths: []
+ recipes: []

0 comments on commit 8b4efad

Please sign in to comment.