require 'railsmachine/recipes/svn' require 'railsmachine/recipes/mysql' require 'railsmachine/recipes/apache' require 'railsmachine/recipes/mongrel' Capistrano.configuration(:must_exist).load do set :app_symlinks, nil desc <<-DESC A macro task that calls setup, setup_db, setup_app, setup_symlinks, and setup_web. Used to configure your deployment environment in one command. DESC task :setup_servers do setup begin setup_db rescue puts "setup_db failed!" end setup_app setup_symlinks setup_web end desc <<-DESC A macro task that calls setup_db, setup_app, setup_symlinks, and setup_web. Used to configure your deployment environment in one command. DESC task :setup_app, :roles => :app do set :mongrel_environment, rails_env set :mongrel_port, apache_proxy_port set :mongrel_servers, apache_proxy_servers set :mongrel_user, user unless mongrel_user set :mongrel_group, mongrel_user unless mongrel_group set_mongrel_conf configure_mongrel_cluster end desc "Restart application server." task :restart_app, :roles => :app do set_mongrel_conf restart_mongrel_cluster end desc "Start application server." task :start_app, :roles => :app do set_mongrel_conf start_mongrel_cluster end desc "Stop application server." task :stop_app, :roles => :app do set_mongrel_conf stop_mongrel_cluster end def set_mongrel_conf set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf end desc "Setup web server." task :setup_web, :roles => :web do set :apache_server_name, domain unless apache_server_name configure_apache end desc "Restart web server." task :restart_web, :roles => :web do restart_apache end desc "Reload web server configuration." task :reload_web, :roles => :web do reload_apache end desc "Start web server." task :start_web, :roles => :web do start_apache end desc "Stop web server." task :stop_web, :roles => :web do stop_apache end desc "Setup database server." task :setup_db, :roles => :db, :only => { :primary => true } do setup_mysql end desc "Setup source control server." task :setup_scm, :roles => :scm do begin setup_svn rescue puts "setup_svn failed!" end import_svn end desc "Setup public symlink directories" task :setup_symlinks, :roles => [:app, :web] do if app_symlinks app_symlinks.each { |link| run "mkdir -p #{shared_path}/public/#{link}" } end end desc "Link up any public directories." task :symlink_public, :roles => [:app, :web] do if app_symlinks app_symlinks.each { |link| run "ln -nfs #{shared_path}/public/#{link} #{current_path}/public/#{link}" } end end desc <<-DESC Restart the processes on the application server by calling restart_app. DESC task :restart, :roles => :app do restart_app end desc <<-DESC Start the processes on the application server by calling start_app. DESC task :spinner, :roles => :app do start_app end desc "Creates additional symlinks." task :after_symlink, :roles => [:app, :web] do symlink_public end end