Skip to content
This repository

Callbacks being run twice #117

OiNutter opened this Issue · 4 comments

3 participants

Will McKenzie Кирилл Lee Hambley
Will McKenzie

I'm getting a strange issue where my after callbacks are being called twice which is causing the deployment to fail as it's trying to create files that it's already created and therefore getting conflicts. Interestingly it is only displaying the triggering after callbacks for <task_name> message once but is executing the callbacks twice.

My deploy.rb is as follows:

# What is the name of the local application?
set :application, <app_name>

# What user is connecting to the remote server?
set :user, <user>

# Where is the local repository?
set :repository, <repo_path>
set :local_repository,  <remote_path>

# What is the production server domain?
role :web, "vserver"

# What remote directory hosts the production website?
set :deploy_to,   <deploy_path>

# Is sudo required to manipulate files on the remote server?
set :use_sudo, false

# What version control solution does the project use?
set :scm,        :git
set :branch,     'master'

# How are the project files being transferred?
set :deploy_via, :remote_cache

# Maintain a local repository cache. Speeds up the copy process.
set :copy_cache, true

# Ignore any local files?
set :copy_exclude, %w(.git,deployment,.project)

#enabled submodules
set :git_enable_submodules, 1

set :group_writable, false

ssh_options[:forward_agent] = true

after "deploy:setup", "summit:change_permissions", "summit:create_htaccess", "summit:create_shares"

after "deploy:symlink", "summit:change_permissions", "summit:switch_htaccess"
after "deploy:rollback", "summit:change_permissions"

namespace :summit do 
  #generates default htaccess file to redirect to current
      task :create_htaccess, :roles =>:web do
      run 'echo -e "Options +FollowSymlinks\nRewriteEngine On\nRewriteCond %{REQUEST_URI} !^/current          /\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule ^(.*)$   /current/\$1 [NC,QSA]\n\nRewriteRule ^(/)?$ /current/ [NC,QSA]" > /path/to/.htaccess'

  #create required shared folders
  task :create_shares, :roles=>:web do
    run 'mkdir /path/to/shared/uploads && sudo chmod 777 /path/to/shared/uploads'
    run 'mkdir /path/to/shared/batches && sudo chmod 777 /path/to/shared/batches'
    run 'mkdir /path/to/shared/config'

  #update the permissions
  task :change_permissions, :roles => :web do
    run "sudo chown -R <user>:<user> #{deploy_to}"
    run "sudo chmod 755 #{deploy_to}"
    run "sudo chmod -R 755 #{deploy_to}releases"

  #link the admin config file
  task :link_admin_config do
   run "ln -s #{shared_path}/configs/admin-config.json #{current_release}/admin/config/site/config.json"

  #upload the admin config files
  task :put_admin_config do
      upload("admin/config/site/config.json","#{shared_path}/configs/admin-config.json",:via => :scp, :mode => '755')
      puts 'Admin config uploaded'
      puts 'No JSON File To Upload'

  upload("admin/app/assets/css/sass/_colours.scss","#{shared_path}/configs/admin-colours.scss",:via => :scp,     :mode => '755')
      puts 'Admin CSS constants uploaded'
      puts 'No SASS File To Upload'

  #downloads the admin config files
  task :get_admin_config do
    download("#{shared_path}/configs/admin-config.json","admin/config/site/config.json",:via => :scp)
    download("#{shared_path}/configs/admin-colours.scss","admin/app/assets/css/sass/_colours.scss",:via => :scp)

  #deploys admin config files
  task :deploy_admin_config do

  #replaces development htaccess with production version
  task :switch_htaccess, :roles => :web do
    run "mv #{current_release}/.htaccess #{current_release}/.htaccess-development"
    run "cp #{current_release}/.htaccess-production #{current_release}/.htaccess"


I'm using railsless-deploy as it's a PHP site, with capistrano 2.9.0 on Cygwin


I think that I have the same issue. Is any solution for this?

Lee Hambley

I haven't been able to replicate this, you are preventing the regular deploy file from loading, right? (railsless deploy readme, ensure that you don't load 'deploy' and railsless deploy.


@leehambley Thanks! I had double include for my config/deploy.rb file

Will McKenzie

Gah! What a muppet! My original version of my Capfile definitely didn't have this, as I'd copied it from a tutorial online, but obviously at some point in getting this set up I'd replaced it and forgot to remove the original calls, so I had double includes for both deploy and my config/deploy.rb file.

I'm just gonna go bang my head on a desk in shame! Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.