Skip to content

Commit

Permalink
capistrano integration. pp-extensions not neeed anymore for rails_deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
emiltin committed May 6, 2009
1 parent 3f93348 commit 7e4a5f2
Show file tree
Hide file tree
Showing 10 changed files with 527 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Capfile
@@ -0,0 +1,2 @@
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load 'config/deploy'
66 changes: 66 additions & 0 deletions config/deploy.rb
@@ -0,0 +1,66 @@
# Capistrano deploy specification.
# Integrated with poolparty by getting node addresses from poolparty, and use them to set cap roles.


#gain access to poolparry node info
require 'poolparty'
require 'clouds.rb'

main_cloud = :app


#extract the hostnames of running instances from a poolparty cloud
def find_running_nodes cloud
clouds[cloud].nodes(:status=>"running").map { |node| node.hostname }
end

#find the rails deploy object so we can extract info
def find_rails_deploy cloud
clouds[cloud].ordered_resources.find { |node| node.is_a? RailsDeployClass }
end

#assign cap roles to pp nodes
nodes = find_running_nodes(main_cloud) #get addresses of running instance in the poolparty cloud named 'app'
role :app, *nodes
role :web, *nodes
role :db, *nodes

# you must have both the public and the private key in the same folder, the public key should have the extension ".pub"
# you can generate a public key from your private key by using 'ssh-keygen -y' on the command line
ssh_options[:keys] = clouds[main_cloud].keypair.filepath #use the keyfile pointed to in clouds.rb
ssh_options[:user] = "root"


#use info from the rails_deploy block in clouds.rb to set deploy stuff
deployer = find_rails_deploy(main_cloud) || raise("Can't find rails deploy object in clouds.rb!")
deploy_dir = "#{deployer.dsl_options[:dir]}/#{deployer.dsl_options[:name]}"
set :scm, "git"
set :application, deployer.dsl_options[:name]
set :repository, deployer.dsl_options[:repo]
set :deploy_to, deploy_dir


set :branch, "master"
set :deploy_via, :remote_cache
#set :user, "deployer"
#default_run_options[:pty] = true
#ssh_options[:forward_agent] = true


desc <<-DESC
Run whoami on the nodes.
DESC
task :stats do
run "cd #{deploy_dir}/current && RAILS_ENV=production rake stats"
end


desc "tail production log files"
task :logs, :roles => :app do
run "tail -f #{deploy_dir}/shared/log/production.log" do |channel, stream, data|
puts
puts "#{channel[:host]}: #{data}"
# printf '...'
break if stream == :err
end
end
5 changes: 1 addition & 4 deletions config/poolparty/clouds.rb
@@ -1,19 +1,16 @@
require "poolparty-extensions" #you must have the auser-poolparty-extensions gem installed

pool :application do
instances 1
keypair "~/.ec2/testpair" #you need to modify this to point to your EC2 key file

cloud :app do
has_gem_package "rails", :version => "2.3.2" #must match the version specified in the rails environment.rb
has_package "mysql-client"
has_package "mysql-server" #mysql server installation
has_package "mysql-server"
has_package "libmysqlclient15-dev" #so we can install the mysql gem
has_gem_package "mysql" #so rails can talk to mysql
has_service "mysql" #run the mysql server

has_file "/etc/motd", :content => "Welcome!" #login message (message-of-the-day)
has_exec "updatedb" #make the command line 'locate' tool work

has_rails_deploy "my_app" do #deploy our rails app using apache + mod_rails/passenger
dir "/var/www"
Expand Down
23 changes: 23 additions & 0 deletions config/recipes/.svn/all-wcprops
@@ -0,0 +1,23 @@
K 25
svn:wc:ra_dav:version-url
V 55
/repos/!svn/ver/1064/webapp/trunk/webapp/config/recipes
END
clusters.rb
K 25
svn:wc:ra_dav:version-url
V 67
/repos/!svn/ver/1064/webapp/trunk/webapp/config/recipes/clusters.rb
END
dns.rb
K 25
svn:wc:ra_dav:version-url
V 61
/repos/!svn/ver/918/webapp/trunk/webapp/config/recipes/dns.rb
END
logs.rb
K 25
svn:wc:ra_dav:version-url
V 62
/repos/!svn/ver/917/webapp/trunk/webapp/config/recipes/logs.rb
END
64 changes: 64 additions & 0 deletions config/recipes/.svn/entries
@@ -0,0 +1,64 @@
8

dir
3249
https://dev.koblo.com:444/repos/webapp/trunk/webapp/config/recipes
https://dev.koblo.com:444/repos



2008-04-11T21:16:32.233217Z
1064
emil


svn:special svn:externals svn:needs-lock











850aafe4-0746-43d5-bba1-ccadfad06b28

clusters.rb
file




2009-02-11T19:44:36.000000Z
60d00427fe9f2961937b39efc0043f5a
2008-04-11T21:16:32.233217Z
1064
emil

dns.rb
file




2009-02-11T19:44:36.000000Z
d41d8cd98f00b204e9800998ecf8427e
2008-03-16T11:46:45.926645Z
918
emil

logs.rb
file




2009-02-11T19:44:36.000000Z
30cf0dfe0e15c13be50f6f5263c57d6d
2008-03-16T10:00:59.987443Z
917
emil

1 change: 1 addition & 0 deletions config/recipes/.svn/format
@@ -0,0 +1 @@
8

0 comments on commit 7e4a5f2

Please sign in to comment.