deploy: persist changes to session_store iniitalizer [ci skip]

This commit is contained in:
wvengen 2014-02-03 10:53:17 +01:00
parent 84e02b795c
commit d92f3f2298
2 changed files with 17 additions and 5 deletions

View file

@ -17,7 +17,7 @@ set :deploy_to, "/www/apps/#{fetch :application}-#{fetch :stage}"
# more settings which are probably ok
set :log_level, :info
set :linked_files, %w{config/database.yml config/app_config.yml config/initializers/secret_token.rb}
set :linked_files, %w{config/database.yml config/app_config.yml config/initializers/secret_token.rb config/initializers/session_store.rb}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# assuming one server for everything, with one user for deploy and one for resque

View file

@ -5,6 +5,7 @@ namespace :deploy do
desc 'Creates and initialises a new foodsoft instance'
task :initial do
before 'deploy:check:linked_files', 'deploy:initial:touch_shared'
before 'deploy:symlink:linked_files', 'deploy:initial:copy_shared'
before 'deploy:updated', 'deploy:initial:secret_token'
before 'deploy:updated', 'deploy:initial:app_config'
before 'deploy:updated', 'deploy:initial:db:config'
@ -88,10 +89,21 @@ namespace :deploy do
desc 'Touches the shared configuration files (for initial deploy)'
task :touch_shared do
on roles(:app), in: :groups do
execute :mkdir, '-p', shared_path.join("config/initializers")
execute :touch, shared_path.join("config/initializers/secret_token.rb")
execute :touch, shared_path.join("config/app_config.yml")
execute :touch, shared_path.join("config/database.yml")
fetch(:linked_files).each do |file|
execute :touch, shared_path.join(file)
end
end
end
desc 'Copies existing shared configuration files'
task :copy_shared do
on roles(:app), in: :groups do
# workaround nonexistent release_path on first deploy
path = releases_path.join(capture(:ls, releases_path).split("\n").sort.last)
fetch(:linked_files).each do |file|
# TODO copy only if existing destination has zero length
execute "[ -e '#{path.join(file)}' ] && cp '#{path.join(file)}' '#{shared_path.join(file)}'"
end
end
end