require 'mmmultiworks/recipes/svn' require 'mmmultiworks/recipes/mysql' require 'mmmultiworks/recipes/apache' require 'mmmultiworks/recipes/mongrel' Capistrano.configuration(:must_exist).load do set :app_symlinks, nil desc "Setup servers." task :setup_server do setup setup_db setup_app setup_symlinks setup_web end def override_sudo(want = false) old_use_sudo = use_sudo set :use_sudo, want yield set :use_sudo, old_use_sudo end desc "Setup application server." task :setup_app, :roles => :app do set :mongrel_environment, rails_env set :mongrel_port, apache_proxy_port set :mongrel_servers, apache_proxy_servers override_sudo { configure_mongrel_cluster } # add entry to syslog.conf # add entry to newsyslog.conf end desc "Restart application server." task :restart_app, :roles => :app do override_sudo { restart_mongrel_cluster } end desc "Start application server." task :start_app, :roles => :app do override_sudo { start_mongrel_cluster } end desc "Stop application server." task :stop_app, :roles => :app do override_sudo { stop_mongrel_cluster } 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 setup_svn 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