Skip to content

Instantly share code, notes, and snippets.

@marktabler
Created June 11, 2012 20:41
Show Gist options
  • Select an option

  • Save marktabler/2912548 to your computer and use it in GitHub Desktop.

Select an option

Save marktabler/2912548 to your computer and use it in GitHub Desktop.
Capistrano Config
# Configure these lines for your app prior to launch.
# Application Name is the folder it will deploy to.
# Script Name is the name of the logfile and the god script.
# Start Command is the command god will issue to start the process.
APPLICATION_NAME = "FayeServer"
SCRIPT_NAME = "faye"
REPOSITORY = "git://github.com/HungryAcademyTeam4/FayeServer.git"
START_COMMAND = 'rainbows /apps/FayeServer/current/faye.ru -c /apps/FayeServer/current/rainbows.conf -E production -p 9000'
# This assumes you want to launch to Falling Foundry.
# If you want to launch to Falling Garden, launch with
# DEPLOY_MODE="staging" cap deploy
PRODUCTION_SERVER = "fallingfoundry.com"
STAGING_SERVER = "fallinggarden.com"
MODE = ENV["DEPLOY_MODE"] || "production"
SERVER = MODE == "staging" ? STAGING_SERVER : PRODUCTION_SERVER
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
server SERVER, :web, :db, :app, primary: true
set :user, "root"
set :application, APPLICATION_NAME
set :deploy_to, "/apps/#{application}"
set :deploy_via, :remote_cache
set :scm, "git"
set :repository, REPOSITORY
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
namespace :deploy do
namespace :assets do
task :precompile do
logger.info "Skipping precompilation of assets"
end
end
end
namespace :deploy do
task :mkdirs do
run "mkdir /apps/#{application}/releases/current -p"
run "mkdir /apps/god_scripts -p"
end
task :create_god_script do
run "cd / && god"
run %^cd /apps/god_scripts && touch #{SCRIPT_NAME}.rb && rm #{SCRIPT_NAME}.rb && touch #{SCRIPT_NAME}.rb^
run %^echo God.watch do \\\|w\\\| >> /apps/god_scripts/#{SCRIPT_NAME}.rb^
run %^echo w.log = \\\"/#{SCRIPT_NAME}.log\\\" >> /apps/god_scripts/#{SCRIPT_NAME}.rb^
run %^echo w.name = \\\"#{SCRIPT_NAME}\\\" >> /apps/god_scripts/#{SCRIPT_NAME}.rb^
run %^echo w.start = \\\"#{START_COMMAND}\\\" >> /apps/god_scripts/#{SCRIPT_NAME}.rb^
run %^echo w.keepalive >> /apps/god_scripts/#{SCRIPT_NAME}.rb^
run %^echo end >> /apps/god_scripts/#{SCRIPT_NAME}.rb^
end
task :bundle do
run "cd /apps/#{application}/current && bundle install --system"
end
task :start do
run "cd / && god load apps/god_scripts/#{SCRIPT_NAME}.rb"
run "cd / && god start #{SCRIPT_NAME}"
end
task :stop do
run "cd / && god stop #{SCRIPT_NAME}"
end
task :restart do
stop
start
end
before "deploy", "deploy:mkdirs"
before "deploy", "deploy:create_god_script"
after "deploy", "deploy:bundle"
after "deploy", "deploy:start"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment