Capistrano::Configuration.instance(:must_exist).load do namespace :deploy do desc <<-DESC [internal] Touches up the released code. This is called by update_code \ after the basic deploy finishes. It assumes a Rails project was deployed, \ so if you are deploying something else, you may want to override this \ task with your own environment's requirements. This task will make the release group-writable (if the :group_writable \ variable is set to true, which is the default). It will then set up \ symlinks to the shared directory for the log, system, and tmp/pids \ directories, and will lastly touch all assets in {media_root}/images, \ {media_root}/stylesheets, and {media_root}/javascripts so that the times are \ consistent (so that asset timestamping works). This touch process \ is only carried out if the :normalize_asset_timestamps variable is \ set to true, which is the default. DESC task :finalize_update, :except => { :no_release => true } do run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true) run <<-CMD ln -s #{shared_path}/system #{latest_release}/#{media_root} && ln -s #{django_path}/django/contrib/admin/media #{latest_release}/#{media_root}/#{admin_media_root} CMD if fetch(:normalize_asset_timestamps, true) stamp = Time.now.utc.strftime("%Y%m%d%H%M.%S") asset_paths = %w(images stylesheets javascripts).map { |p| "#{latest_release}/#{media_root}/#{p}" }.join(" ") run "find #{asset_paths} -exec touch -t #{stamp} {} ';'; true", :env => { "TZ" => "UTC" } end end desc <<-DESC [internal] Creates upload directories in /shared/system that your app may need. DESC task :create_upload_directories, :roles => :app do upload_directories.each do |dir| run "mkdir -p #{shared_path}/system/#{dir}" end writable_directories end after('deploy:setup','deploy:create_upload_directories') desc "[internal] Chgrp -R of /shared/system writable by the apache group" task :writable_directories, :roles => :app do sudo "chown -R #{user}:#{apache_group} #{shared_path}/system" sudo "chmod -R g+w #{shared_path}/system" end desc "Starts the application server" task :start, :roles => :app do sudo "#{start_cmd}" end desc "Stops the application server" task :stop, :roles => :app do sudo "#{stop_cmd}" end desc "Restarts the application server" task :restart, :roles => :app do sudo "#{restart_cmd}" end desc "Reloads the application server" task :reload, :roles => :app do sudo "#{reload_cmd}" end desc "Deletes everything in #{deploy_to}" task :clobber, :roles => :app do sudo "rm -rf #{deploy_to}/*" end # tasks that don't do anythign with django no_ops = ['migrate', 'migration'] no_ops.each do |name| task name do ; end end desc "Runs syncdb" task :syncdb, :roles => :app do run "cd #{app_path} ; ./manage.py syncdb --setting=#{settings}" end end end