0
-require 'mongrel_cluster/recipes'
0
+# Required for using Mongrel with Capistrano2
0
+require 'palmtree/recipes/mongrel_cluster'
0
+require 'highline/import'
0
########################################################################
0
# Rails Boxcar - Capistrano Deployment Recipe
0
@@ -7,9 +10,7 @@ require 'mongrel_cluster/recipes'
0
# What is the name of your application? (no spaces)
0
# set :application_name, 'my_cool_app'
0
-set :application_name, 'rubyurl'
0
-set :domain_names, 'rubyurl.com'
0
+set :application_name, 'my_cool_app'
0
# What is the hostname of your Rails Boxcar server?
0
@@ -19,33 +20,36 @@ set :boxcar_server, '198.145.115.75'
0
# What is the username of your Rails Boxcar user that you want
0
# to deploy this application with?
0
-# set :boxcar_username = 'johnny'
0
+# set :boxcar_username, 'johnny'
0
set :boxcar_username, 'rubyurl'
0
# Where is your source code repository?
0
# set :repository = 'http://svn.railsboxcar.com/my_cool_app/tags/CURRENT'
0
-set :repository, 'https://svn.roundhaus.com/planetargon/rubyurl_2-0/trunk'
0
-set :checkout, 'export'
0
+set :svn_username, 'rubyurl'
0
+set :svn_repository_url, 'https://svn.roundhaus.com/planetargon/rubyurl_2-0/trunk'
0
# What database server are you using?
0
-set :database_adapter, 'postgresql'
0
set :database_name, { :development => 'rubyurl_development',
0
:test => 'rubyurl_test',
0
:production => 'rubyurl_production' }
0
-# What port number is your database running on?
0
-set :database_port, 5432
0
-# What port number should your mongrel cluster start on?
0
-set :mongrel_port, 8000
0
-# How many instances of mongrel should be in your cluster?
0
-set :mongrel_servers, 3
0
########################################################################
0
# Advanced Configuration
0
+# Only the courageous of ninjas dare pass this!
0
########################################################################
0
role :web, boxcar_server
0
@@ -57,83 +61,170 @@ set :user, boxcar_username
0
+set :domain_names, Proc.new { HighLine.ask("What is the primary domain name?") { |q| q.default = "railsboxcar.com" } }
0
+# Ask the user for their subversion password
0
+set :svn_password, Proc.new { HighLine.ask("What is your subversion password for #{svn_username}: ") { |q| q.echo = "x" } }
0
+set :repository, Proc.new { "--username #{svn_username} " + "--password #{svn_password} " + "#{svn_repository_url}" }
0
+set :checkout, 'export'
0
set :db_development,database_name[:development]
0
set :db_test, database_name[:test]
0
set :db_production, database_name[:production]
0
+# Prompt user to set database user/pass
0
+set :database_username, Proc.new { HighLine.ask("What is your database username? ") { |q| q.default = "dbuser" } }
0
+set :database_host, Proc.new { HighLine.ask("What host is your database running on? ") { |q| q.default = "localhost" } }
0
+set :database_adapter, Proc.new {
0
+ menu.prompt = "What database server will you be using?"
0
+ menu.choices(:postgresql, :mysql)
0
+set :database_password, Proc.new { HighLine.ask("What is your database user's password? ") { |q| q.echo = "x" } }
0
+set :database_socket, Proc.new { HighLine.ask("Where is the MySQL socket file? ") { |q| q.default = "/var/run/mysqld/mysqld.sock" } }
0
+set :database_port, Proc.new {
0
+ HighLine.ask("What port does your database run on? ") do |q|
0
+ if database_adapter.to_s == "postgresql"
0
set :home, "/home/#{user}"
0
set :etc, "#{home}/etc"
0
set :log, "#{home}/log"
0
set :deploy_to, "#{home}/sites/#{application_name}"
0
+set :shared_dir, "#{deploy_to}/shared"
0
+# What port number should your mongrel cluster start on?
0
+set :mongrel_port, Proc.new { HighLine.ask("What port will your mongrel cluster start with? ") { |q| q.default = "8000" } }
0
+# How many instances of mongrel should be in your cluster?
0
+set :mongrel_servers, Proc.new {
0
+ menu.prompt = "How many mongrel servers should run?"
0
set :mongrel_conf, "#{etc}/mongrel_cluster.#{application_name}.conf"
0
set :mongrel_pid, "#{log}/mongrel_cluster.#{application_name}.pid"
0
set :mongrel_address, '127.0.0.1'
0
set :mongrel_environment, :production
0
desc "Create database.yml in shared/config"
0
- database_configuration = render :template => <<-EOF
0
+ puts "###########################################"
0
+ puts " Rails Boxcar - setup process"
0
+ puts "###########################################"
0
+ puts "# STEP 1: Database Configuration"
0
+ puts "###########################################"
0
+ today = Time.now.strftime('%b %d, %Y')
0
+# Generated on #{today} for Rails Boxcar (http://railsboxcar.com)
0
+ case database_adapter.to_s
0
+ database_configuration = <<EOF
0
- adapter: <%= database_adapter %>
0
- port: <%= database_port %>
0
+ adapter: #{database_adapter}
0
+ host: #{database_host}
0
+ port: #{database_port}
0
+ username: #{database_username}
0
+ password: #{database_password}
0
- database: <%= db_development %>
0
+ database: #{db_development}
0
- database: <%= db_test %>
0
- database: <%= db_production %>
0
+ database: #{db_production}
0
- mongrel_cluster_configuration = render :template => <<-EOF
0
-port: <%= mongrel_port %>
0
-pid_file: <%= mongrel_pid %>
0
-servers: <%= mongrel_servers %>
0
-cwd: <%= deploy_to %>/current
0
-environment: production
0
+ database_configuration = <<EOF
0
+ adapter: #{database_adapter}
0
+ host: #{database_host}
0
+ port: #{database_port}
0
+ username: #{database_username}
0
+ password: #{database_password}
0
+ socket: #{database_socket}
0
+ database: #{db_development}
0
+ database: #{db_production}
0
- nginx_generator_configuration = render :template => <<-EOF
0
- #######################################################################
0
- # Add the following to /etc/nginx/nginx.yml
0
- # Then: cd /etc/nginx; generate_nginx_config nginx.yml nginx.conf
0
- #######################################################################
0
- <%= application_name %>:
0
- # The upstream servers to proxy balance.
0
- upstream:<% mongrel_servers.to_i.times do |port| %>
0
- - 127.0.0.1:<%= mongrel_port + port %><% end %>
0
- # Just a string of server names.
0
- server_name: <%= domain_names %>
0
- root: <%= deploy_to %>/current/public
0
- #######################################################################
0
+ mongrel_cluster_configuration = <<EOF
0
+pid_file: #{mongrel_pid}
0
+servers: #{mongrel_servers}
0
+cwd: #{deploy_to}/current
0
+environment: production
0
- run "mkdir -p #{deploy_to}/shared/config"
0
+ puts "###########################################"
0
+ puts "Step 2: Creating necessary directories on\n your Rails Boxcar!"
0
+ puts "###########################################"
0
+ run "mkdir -p #{shared_dir}/config"
0
+ puts "###########################################"
0
+ puts "Step 3: Uploading database.yml to Boxcar"
0
+ puts "###########################################"
0
# Create the database.yml file
0
- put database_configuration, "#{deploy_to}/#{shared_dir}/config/database.yml"
0
+ put database_configuration, "#{shared_dir}/config/database.yml"
0
+ puts "###########################################"
0
+ puts "Step 4: Uploding mongrel cluster config to\n your Rails Boxcar."
0
+ puts "###########################################"
0
# Create mongrel cluster configuration
0
put mongrel_cluster_configuration, mongrel_conf
0
- # Print the nginx configuration information for the person deploying.
0
- puts nginx_generator_configuration
0
+ puts "###########################################"
0
+ puts "DONE! Now run cap deploy:cold"
0
+ puts "###########################################"
0
desc "Link in the production database.yml"
0
task :after_update_code do
0
- run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
0
\ No newline at end of file
0
+ run "ln -nfs #{shared_dir}/config/database.yml #{release_path}/config/database.yml"
Comments
No one has commented yet.