Created
August 17, 2012 08:32
-
-
Save yasuoza/3377028 to your computer and use it in GitHub Desktop.
Capistrano sample setting file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/capistrano" | |
load 'deploy' | |
load 'deploy/assets' | |
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } | |
load 'config/deploy' # remove this line to skip loading any of the default tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Application info | |
set :application, "AppName" | |
set :repository, "git@foobar.git" | |
set :deploy_to, "/PATH/TO/#{application}" | |
set :rails_env, "production" | |
# Use capistrano command for unicorn | |
# https://github.com/sosedoff/capistrano-unicorn | |
require 'capistrano-unicorn' | |
set :unicorn_bin, 'unicorn_rails' | |
# Set rails user | |
set :user, "USER" | |
set :use_sudo, false | |
# Use git repository | |
set :scm, :git | |
role :web, "IP_or_SeverName" # Your HTTP server, Apache/etc | |
role :app, "IP_or_SeverName" # This may be the same as your `Web` server | |
role :db, "IP_or_SeverName", :primary => true # This is where Rails migrations will run | |
# role :db, "your slave db-server here" | |
# bundle install | |
# Configuration for `cap bundle:install` | |
set :bundle_gemfile, "Gemfile" | |
set :bundle_dir, File.join(fetch(:shared_path), 'bundle') | |
set :bundle_without, [:development, :test] | |
set :bundle_cmd, "bundle" # e.g. "/opt/ruby/bin/bundle" | |
set :bundle_roles, {:except => {:no_release => true}} # e.g. [:app, :batch] | |
# Make database directory | |
namespace :database do | |
desc "BackUp current database" | |
task :create_dir, :role => [:app] do | |
run "mkdir -p #{shared_path}/db" | |
end | |
end | |
after 'deploy:update_code', 'database:create_dir' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set your full path to application. | |
application = "AppName" | |
deploy_to = "/PATH/TO/#{application}" | |
# Set unicorn options | |
worker_processes 16 | |
preload_app true | |
timeout 180 | |
listen "/tmp/.sock", :backlog => 64 | |
listen 3000, :tcp_nopush => true | |
# Spawn unicorn master worker for user apps (group: apps) | |
user 'apps', 'apps' | |
# Fill path to your app | |
working_directory "#{deploy_to}/current" | |
# Should be 'production' by default, otherwise use other env | |
rails_env = ENV['RAILS_ENV'] || 'production' | |
# Log everything to one file | |
stderr_path "#{deploy_to}/shared/log/unicorn.log" | |
stdout_path "#{deploy_to}/shared/log/unicorn.log" | |
# Set master PID location | |
pid "#{deploy_to}/shared/pids/unicorn.pid" | |
before_fork do |server, worker| | |
ActiveRecord::Base.connection.disconnect! | |
old_pid = "#{server.config[:pid]}.oldbin" | |
if File.exists?(old_pid) && server.pid != old_pid | |
begin | |
Process.kill("QUIT", File.read(old_pid).to_i) | |
rescue Errno::ENOENT, Errno::ESRCH | |
# someone else did our job for us | |
end | |
end | |
end | |
after_fork do |server, worker| | |
ActiveRecord::Base.establish_connection | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using