diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/.gitignore | 17 | ||||
-rw-r--r-- | config/deploy.rb | 69 | ||||
-rw-r--r-- | config/deploy.yml.example | 13 | ||||
-rw-r--r-- | config/environment.rb | 2 | ||||
-rw-r--r-- | config/packages | 2 |
5 files changed, 93 insertions, 10 deletions
diff --git a/config/.gitignore b/config/.gitignore index 28efb03ec..78d586ea8 100644 --- a/config/.gitignore +++ b/config/.gitignore @@ -1,8 +1,9 @@ -/config.tmp -/general -/general.yml -/database.yml -/rails_env.rb -/logrotate -/memcached.yml -/*.deployed +config.tmp +general +general.yml +database.yml +rails_env.rb +logrotate +memcached.yml +*.deployed +deploy.yml diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 000000000..888710f83 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,69 @@ +require 'bundler/capistrano' + +set :stage, 'staging' unless exists? :stage + +configuration = YAML.load_file('config/deploy.yml')[stage] + +set :application, 'alaveteli' +set :scm, :git +set :deploy_via, :remote_cache +set :repository, configuration['repository'] +set :branch, configuration['branch'] +set :git_enable_submodules, true +set :deploy_to, configuration['deploy_to'] +set :user, configuration['user'] +set :use_sudo, false + +server configuration['server'], :app, :web, :db, :primary => true + +namespace :rake do + namespace :themes do + task :install do + run "cd #{release_path} && bundle exec rake themes:install RAILS_ENV=#{rails_env}" + end + end +end + +# Not in the rake namespace because we're also specifying app-specific arguments here +namespace :xapian do + desc 'Rebuilds the Xapian index as per the ./scripts/rebuild-xapian-index script' + task :rebuild_index do + run "cd #{current_path} && bundle exec rake xapian:rebuild_index models='PublicBody User InfoRequestEvent' RAILS_ENV=#{rails_env}" + end +end + +namespace :deploy do + desc "Restarting mod_rails with restart.txt" + task :restart, :roles => :app, :except => { :no_release => true } do + run "touch #{current_path}/tmp/restart.txt" + end + + [:start, :stop].each do |t| + desc "#{t} task is a no-op with mod_rails" + task t, :roles => :app do ; end + end + + desc 'Link configuration after a code update' + task :symlink_configuration do + links = { + "#{release_path}/config/database.yml" => "#{shared_path}/database.yml", + "#{release_path}/config/general.yml" => "#{shared_path}/general.yml", + "#{release_path}/files" => "#{shared_path}/files", + "#{release_path}/cache" => "#{shared_path}/cache", + "#{release_path}/vendor/plugins/acts_as_xapian/xapiandbs" => "#{shared_path}/xapiandbs", + "#{release_path}/public/download" => "#{release_path}/cache/zips/download" + } + + # "ln -sf <a> <b>" creates a symbolic link but deletes <b> if it already exists + run links.map {|a| "ln -sf #{a.last} #{a.first}"}.join(";") + end + + after 'deploy:setup' do + run "mkdir -p #{shared_path}/files" + run "mkdir -p #{shared_path}/cache" + run "mkdir -p #{shared_path}/xapiandbs" + end +end + +after 'deploy:update_code', 'deploy:symlink_configuration' +after 'deploy:update_code', 'rake:themes:install' diff --git a/config/deploy.yml.example b/config/deploy.yml.example new file mode 100644 index 000000000..aea045dff --- /dev/null +++ b/config/deploy.yml.example @@ -0,0 +1,13 @@ +# Site-specific deployment configuration lives in this file +production: + repository: git://github.com:mysociety/alaveteli.git + branch: master + server: www.example.com + user: deploy + deploy_to: /srv/www/alaveteli_production +staging: + repository: git://github.com:mysociety/alaveteli.git + branch: develop + server: test.example.com + user: deploy + deploy_to: /srv/www/alaveteli_staging diff --git a/config/environment.rb b/config/environment.rb index 6234ae5c1..250d3eed0 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -32,7 +32,7 @@ require File.join(File.dirname(__FILE__), '../lib/old_rubygems_patch') # Application version -ALAVETELI_VERSION = '0.6.5.1' +ALAVETELI_VERSION = '0.6.6' Rails::Initializer.run do |config| # Load intial mySociety config diff --git a/config/packages b/config/packages index d059d2906..3cffcb0f9 100644 --- a/config/packages +++ b/config/packages @@ -9,7 +9,7 @@ irb wv poppler-utils pdftk (>> 1.41+dfsg-1) | pdftk (<< 1.41+dfsg-1) # that version has a non-functionining uncompress option -gs-gpl +ghostscript catdoc links elinks |