deploy.cap revision 9f1ac4e2ee7794ab7189ead9549a60004d4c4088
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app) do
execute :touch, release_path.join('tmp/restart.txt')
end
end
desc "Saves the current revision to release_path/REVISION"
task :set_revision do
on roles(:app) do
# dump current git revision
rev = capture "cd #{repo_path} && git rev-parse --short #{fetch :branch}"
execute :echo, "#{rev} > #{release_path}/REVISION"
end
end
desc "Moves and replaces the secret-token if missing in shared directory"
task :symlink_secret do
on roles(:app) do
filename = 'secret_token.rb'
release_secret = release_path.join("config/initializers/#{filename}")
shared_secret = shared_path.join("config/#{filename}")
unless test "[ -f #{shared_secret} ]"
within release_path do
execute :rake, "secret:replace"
end
execute :mkdir, "-p #{shared_path.join('config')}"
execute :mv, "#{release_secret} #{shared_secret}"
end
# symlink secret token
execute :ln, "-nfs #{shared_secret} #{release_secret}"
end
end
desc "Create Hets Instance if neccessary"
task :create_hets_instances do
on roles(:app) do
execute :rake, "hets:generate_first_instance"
end
end
after :updated, :create_hets_instances
after :updated, :symlink_secret
after :updated, :set_revision
after :publishing, :restart
end