I tried to write a capistrano script where I have a copy configuration file from my application's directory ( support/config/#{rails_env}) in shared directory(shared / config) in capistrano
rails_env => 'staging'
So, when capistrano starts first time, it sorts the file from the directory support/config/#{rails_env}into the shared / config directory, but it needs to run it before the file is connected by capistrano, i.e. before this is done
set :linked_files, %w{config/api_config.yml}
so the related task will not work (since the task requires the file to be present in the shared folder)
Here is my Capfile (nothing out of the ordinary since most things have been done by my capistrno)
set :application, 'custom-api'
set :repo_url, ''
set :rails_env, 'staging'
set :deploy_to, '/var/apps/staging/custom-api'
set :scm, :git
set :format, :pretty
set :log_level, :debug
set :rvm_type, :user
set :rvm_ruby_version, 'ruby-1.9.3@484@custom-api'
set :linked_files, %w{config/mongoid.yml config/api_config.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :keep_releases, 5
namespace :deploy do
desc 'Copy files from application to shared directory'
task :copy_files do
on roles(:app) do
execute :cp ,'-r',release_path.join('support/config'),shared_path
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
after :finishing, 'deploy:cleanup'
end
All I need to do is something like
before 'deploy:[task_name]' , 'deploy:copy_files'
Added Note: Using Capistrno 3.0.1