Hello all!
We have a problem with deploying our Rails app. We use capistrano-ext
for multistage use. The stages we have are: staging and production.
The problem is with staging and it is that sometimes when updates have
been made not all of them are shown on the page. Even though the code
in the folder that "current" points to is correct. So after a cap some
of the new functionality is shown, and some stuff are old that should
have been updated.
I think that the problem is some kind of cache. Why? As an example we
had this problem a few months ago. We generate graphs on the site and
after an update on these and then a cap some graphs was still showing
old stuff. So I thought I'd try to remove all old releases (all but
the one current points at). After I did that I refreshed the browser
and the site "crashed" (Can't remember the error that was shown).
After pressing F5 a couple of times the site got on it's feet again
with all new functionality. So something was in this case "pointing"
to an old release.
I'm of course not sure if it's capistrano causing the problem, but I
had to start somewhere...
What can I try?
These are the configs used:
# deploy.rb
set :application, "appx"
# So that you can choose branch
# Example: cap staging deploy --set-before branch=my-branch
if variables.include?(:branch)
set :repository, "svn+ssh://.../svn/appx/branches/#{branch}"
else
set :repository, "svn+ssh://.../svn/appx/trunk/appx"
end
set :user, "appx"
set :password, "X"
set :use_sudo, false
role :web, "appx.se"
role :app, "appx.se"
role :db, "appx.se", :primary => true
# see config/deploy/production.rb and config/deploy/staging.rb
# for stage specific settings.
set :stages, %w(staging production testing)
set :default_stage, "staging"
require 'capistrano/ext/multistage'
namespace :deploy do
task :restart do
run "mongrel_rails cluster::restart -C #{mongrel_config}"
end
task :start do
run "mongrel_rails cluster::start -C #{mongrel_config}"
end
task :stop do
run "mongrel_rails cluster::stop -C #{mongrel_config}"
end
end
after 'deploy:update_code', 'deploy:fix_stuff'
# deploy/staging.rb
set :checkout, "update"
set :deploy_to, "/var/app/appx-staging"
set :mongrel_config, "/etc/mongrel_cluster/appx-staging.yml"
namespace :deploy do
task :migrate, :roles => :db, :only => { :primary => true } do
rails_env = "staging"
migrate_env = fetch(:migrate_env, "")
migrate_target = fetch(:migrate_target, "latest")
directory = case migrate_target.to_sym
when :current then current_path
when :latest then current_release
else
raise ArgumentError,
"you must specify one of 'current' or 'latest' for
migrate_target"
end
run "cd #{directory} && " +
"/usr/bin/rake RAILS_ENV=#{rails_env} #{migrate_env}
db:migrate"
end
task :fix_stuff, :roles => :app do
rails_env = "staging"
# link in shared/database.yml
run "ln -nfs #{shared_path}/database.yml #{release_path}/config/
database.yml"
run "ln -nfs #{shared_path}/documents #{release_path}/documents"
run "ln -nfs #{shared_path}/help #{release_path}/public/images/
help"
# set permissions
run "find #{release_path}/public -type d -exec chmod 0755 {} \\;"
run "find #{release_path}/public -type f -exec chmod 0644 {} \\;"
run "chmod 0755 #{release_path}/public/dispatch.*"
# build assets
run "cd #{release_path} && RAILS_ENV=#{rails_env} rake
asset:packager:build_all"
end
end
Thanks!
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---