Update cap scripts to have separate staging and production environments, use bundler
This commit is contained in:
parent
a6c1b5bf59
commit
a2bb8515f9
7 changed files with 118 additions and 16 deletions
3
Gemfile
3
Gemfile
|
|
@ -30,7 +30,8 @@ gem 'roxml', :git => 'git://github.com/Empact/roxml.git', :ref => '7ea9a9ffd2338
|
|||
gem 'addressable', '2.2.2', :require => 'addressable/uri'
|
||||
gem 'json', '1.4.6'
|
||||
gem 'http_accept_language', :git => 'git://github.com/iain/http_accept_language.git', :ref => '0b78aa7849fc90cf9e12'
|
||||
gem 'capistrano', '2.5.19'
|
||||
gem 'capistrano', '2.5.19', :require => false
|
||||
gem 'capistrano-ext', '1.2.1', :require => false
|
||||
|
||||
gem 'thin', '1.2.7', :require => false
|
||||
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ GEM
|
|||
net-sftp (>= 2.0.0)
|
||||
net-ssh (>= 2.0.14)
|
||||
net-ssh-gateway (>= 1.0.0)
|
||||
capistrano-ext (1.2.1)
|
||||
capistrano (>= 1.0.0)
|
||||
capybara (0.3.9)
|
||||
culerity (>= 0.2.4)
|
||||
mime-types (>= 1.16)
|
||||
|
|
@ -379,6 +381,7 @@ DEPENDENCIES
|
|||
aws (= 2.3.32)
|
||||
bundler (>= 1.0.0)
|
||||
capistrano (= 2.5.19)
|
||||
capistrano-ext (= 1.2.1)
|
||||
capybara (~> 0.3.9)
|
||||
carrierwave!
|
||||
chef (= 0.9.12)
|
||||
|
|
|
|||
|
|
@ -2,26 +2,22 @@
|
|||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
config = YAML.load_file(File.dirname(__FILE__) + '/deploy_config.yml')
|
||||
config = config['production']
|
||||
set :config_yaml, YAML.load_file(File.dirname(__FILE__) + '/deploy_config.yml')
|
||||
|
||||
set :rails_env, 'production'
|
||||
require 'bundler/capistrano'
|
||||
set :bundle_dir, ''
|
||||
|
||||
set :stages, ['production', 'staging']
|
||||
set :default_stage, 'staging'
|
||||
require 'capistrano/ext/multistage'
|
||||
|
||||
set :application, 'diaspora'
|
||||
set :deploy_to, config['deploy_to']
|
||||
set :current_dir, config['current_dir']
|
||||
|
||||
set :scm, :git
|
||||
set :user, config['user']
|
||||
set :password, config['password']
|
||||
set :use_sudo, false
|
||||
set :scm_verbose, true
|
||||
set :repository, config['repo']
|
||||
set :repository_cache, "remote_cache"
|
||||
set :deploy_via, :checkout
|
||||
|
||||
server config['server'], :app, :web, :db, :primary => true
|
||||
|
||||
namespace :deploy do
|
||||
task :symlink_config_files do
|
||||
run "ln -s -f #{shared_path}/config/database.yml #{current_path}/config/database.yml"
|
||||
|
|
@ -39,16 +35,34 @@ namespace :deploy do
|
|||
end
|
||||
|
||||
task :restart do
|
||||
run "killall ruby"
|
||||
thins = run "svstat /service/thin*"
|
||||
matches = thins.match(/(thin_\d+)/).to_a
|
||||
|
||||
matches.each_with_index do |thin, index|
|
||||
unless index == 0
|
||||
puts "sleeping for 10 seconds"
|
||||
sleep(10)
|
||||
end
|
||||
run "svc -t /service/#{thin}"
|
||||
end
|
||||
|
||||
run "svc -t /service/resque_worker*"
|
||||
end
|
||||
|
||||
task :kill do
|
||||
run "svc -k /service/thin*"
|
||||
run "svc -k /service/resque_worker*"
|
||||
end
|
||||
|
||||
task :start do
|
||||
# daemontools FTW
|
||||
run "svc -u /service/thin*"
|
||||
run "svc -u /service/resque_worker*"
|
||||
end
|
||||
|
||||
task :stop do
|
||||
run "killall ruby"
|
||||
run "svc -d /service/thin*"
|
||||
run "svc -d /service/resque_worker*"
|
||||
end
|
||||
end
|
||||
|
||||
after "deploy:symlink", "deploy:symlink_config_files", "deploy:symlink_cookie_secret", "deploy:bundle_static_assets"
|
||||
after "deploy:symlink", "deploy:symlink_config_files", "deploy:symlink_cookie_secret", "deploy:bundle_static_assets"
|
||||
|
|
|
|||
11
config/deploy/production.rb
Normal file
11
config/deploy/production.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
set :config, config_yaml['production']
|
||||
|
||||
set :deploy_to, config['deploy_to']
|
||||
set :current_dir, config['current_dir']
|
||||
set :rails_env, config['rails_env']
|
||||
set :user, config['user']
|
||||
if config['password']
|
||||
set :password, config['password']
|
||||
end
|
||||
set :repository, config['repo']
|
||||
server config['server'], :app, :web, :db, :primary => true
|
||||
11
config/deploy/staging.rb
Normal file
11
config/deploy/staging.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
set :config, config_yaml['staging']
|
||||
|
||||
set :deploy_to, config['deploy_to']
|
||||
set :current_dir, config['current_dir']
|
||||
set :rails_env, config['rails_env']
|
||||
set :user, config['user']
|
||||
if config['password']
|
||||
set :password, config['password']
|
||||
end
|
||||
set :repository, config['repo']
|
||||
server config['server'], :app, :web, :db, :primary => true
|
||||
|
|
@ -8,4 +8,13 @@ production:
|
|||
current_dir: 'diaspora'
|
||||
user: 'diaspora'
|
||||
password: 'password'
|
||||
rails_env: 'production'
|
||||
repo: 'git://github.com/diaspora/diaspora.git'
|
||||
staging:
|
||||
server: 'staging.example.com'
|
||||
deploy_to: '/var/www/diaspora'
|
||||
current_dir: 'diaspora'
|
||||
user: 'diaspora'
|
||||
password: 'password'
|
||||
rails_env: 'staging'
|
||||
repo: 'git://github.com/diaspora/diaspora.git'
|
||||
|
|
|
|||
53
config/environments/staging.rb
Normal file
53
config/environments/staging.rb
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
Diaspora::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
|
||||
# The production environment is meant for finished, "live" apps.
|
||||
# Code is not reloaded between requests
|
||||
config.cache_classes = true
|
||||
|
||||
# Full error reports are disabled and caching is turned on
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Specifies the header that your server uses for sending files
|
||||
#config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
||||
|
||||
config.active_support.deprecation = :notify
|
||||
|
||||
# For nginx:
|
||||
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
||||
|
||||
# If you have no front-end server that supports something like X-Sendfile,
|
||||
# just comment this out and Rails will serve the files
|
||||
|
||||
# See everything in the log (default is :info)
|
||||
# config.log_level = :debug
|
||||
|
||||
# Use a different logger for distributed setups
|
||||
# config.logger = SyslogLogger.new
|
||||
|
||||
# Use a different cache store in production
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Disable Rails's static asset server
|
||||
# In production, Apache or nginx will already do this
|
||||
config.serve_static_assets = false
|
||||
|
||||
# Enable serving of images, stylesheets, and javascripts from an asset server
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
|
||||
# Disable delivery errors, bad email addresses will be ignored
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
||||
# the I18n.default_locale when a translation can not be found)
|
||||
config.i18n.fallbacks = true
|
||||
config.threadsafe!
|
||||
end
|
||||
|
||||
# Sacrifice readability for a 10% performance boost
|
||||
Haml::Template::options[:ugly] = true
|
||||
Loading…
Reference in a new issue