Skip to content

Instantly share code, notes, and snippets.

@wedtm
Created August 11, 2009 17:19
Show Gist options
  • Select an option

  • Save wedtm/165971 to your computer and use it in GitHub Desktop.

Select an option

Save wedtm/165971 to your computer and use it in GitHub Desktop.
##############################
## Vimae Development
## Capistrano Deploy.rb
## Modified 08/10/2009
##############################
####
## Setup the role servers
role :web, "vimae.com"
role :app, "vimae.com"
role :db, "vimae.com", :primary => true
####
## Contextual Variables
set :scm_server, 'scm.vimae.com'
set :admin_email, '[email protected]'
####
## Set up variables
set :application, "vimae.com"
set :deploy_to, "/var/www/#{application}"
set :runner, "deploy"
set :user, "deploy"
set :use_sudo, false
####
## Git configuration
set :scm, :git
set :scm_username, "deploy"
set :repository, "[email protected]:/var/repos/#{application}"
set :branch, "master"
default_run_options[:pty] = true
####
## Setup thin configuration options
set :thin_config_location, "/etc/thin/#{application}.yml"
set :thin_config, {
:pid => "tmp/pids/thin.pid", # The directory where the thin configuration files are stored
:log => "log/thin.log", # Sets the entire process up as production
:port => 3006, # The user to run the processes under
:max_conns => 1024, # The group that the processes will run under
:timeout => 30, # Which address on the server you'd like to bind to
:chdir => "#{deploy_to}/current/", # The number of worker threads that will be spawned
:max_persistent_conns => 512, # The port that the workers will start on. Each subsequent process will start at the next port.
:environment => "production", # The envrionment that the Rails server should start in
:servers => 3, # The number of servers that
:address => '0.0.0.0', # The address to bind to
:daemonize => true, # Running the process as daemons
:tag => "#{application}" # Tags the processes so they are easier to find in top/htop
}
####################################
## NOTHING BELOW SHOULD BE EDITED ##
####################################
set :timestamp, Date.new
####
## Thin namespace
namespace :thin do
desc 'Write thin config to the thin config directory.'
task :setup, :roles => :app do
config = ""
thin_config.each do |key, value|
config << key.to_s << ": " << value.to_s << "\n"
end
put config, thin_config_location
end
end
####
## Custom Deploy Namespace for deployment on Thin
namespace :deploy do
desc 'Start the Thin processes up on the app servers.'
task :start, :roles => :app do
run "cd #{thin_config[:chdir]}; thin start -C #{thin_config_location}"
end
desc 'Stop the Thin processes on the app servers.'
task :stop, :roles => :app do
run "cd #{thin_config[:chdir]}; thin stop -C #{thin_config_location}"
end
desc 'Restart the Thin processes on the app servers.'
task :restart, :roles => :app do
run "cd #{thin_config[:chdir]}; thin restart -C #{thin_config_location}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment