Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- load 'deploy'
- set :user, 'deploy'
- set :use_sudo, false
- set :ssh_options, {:forward_agent => true}
- # =============
- set :scm, 'git'
- set :scm_user, 'equal'
- set :repository, 'git@github.com:equal/equality.git'
- set :deploy_via, :remote_cache
- # Deploy everything to equality-versions and symlink equality
- # Non-standard, but probably best.
- set :deploy_to, '/sites'
- set :version_dir, 'eq-versions'
- set :repository_cache, 'eq-versions/_cache'
- set :current_dir, "equality"
- # We don't need shared
- set :shared_dir, ''
- set :shared_children, %w()
- # ==========================================
- set :branch, 'master'
- set :stages, ['production']
- task :production do
- set :stage, 'production'
- set :branch, 'master'
- role :proxy, "eq-production"
- role :backend, "eq-production"
- end
- # ==========================================
- namespace 'deploy' do
- desc <<-DESC
- Prepare one or more servers for deployment. Override the default \
- because we do not want to be bothered with the "shared" stuff in
- our environment.
- DESC
- task :setup, :except => { :no_release => true } do
- dirs = [deploy_to, releases_path]
- run "mkdir -p #{dirs.join(' ')} && chown deploy:developers #{dirs.join(' ')} && chmod g+w #{dirs.join(' ')}"
- end
- desc <<-DESC
- Overriding this method so that we can use goddamn sudo
- Updates the symlink to the most recently deployed version. Capistrano works \
- by putting each new release of your application in its own directory. When \
- you deploy a new version, this task's job is to update the `current' symlink \
- to point at the new version. You will rarely need to call this task \
- directly; instead, use the `deploy' task (which performs a complete \
- deploy, including `restart') or the 'update' task (which does everything \
- except `restart').
- DESC
- task :symlink, :except => { :no_release => true } do
- on_rollback do
- if previous_release
- run "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true"
- else
- logger.important "no previous release to rollback to, rollback of symlink skipped"
- end
- end
- run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
- end
- desc <<-DESC
- [internal] Override this task, which assumes that \
- you are working in a rails environment, which we \
- are most certainly not.
- DESC
- task :finalize_update do
- #run "cd #{current_path} && git checkout master"
- end
- desc 'restart all servers (no-op for now)'
- task :restart do
- end
- end
- namespace 'restart' do
- desc 'restart all servers'
- task :default do
- proxy
- backend
- end
- desc 'restart proxy servers'
- task :proxy, :roles => :proxy do
- sudo('/etc/init.d/nginx restart')
- end
- desc 'restart backend servers'
- task :backend, :roles => :backend do
- sudo('/etc/init.d/apache2 force-reload')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement