cap deploy:setup
# will create shared dir's and symlinks for assets
# db, log and "public/system"
cap deploy
# Let's go
Created
October 18, 2011 08:08
-
-
Save zealot128/1294860 to your computer and use it in GitHub Desktop.
pludoni Capistrano Deploy script
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
USE_WHENEVER = false | |
USE_SPHINX = false | |
TARGET_PATH = "/var/www/vhosts/it-jobs-und-stellen.de/subdomains/notes/httpdocs" | |
TARGET_URL = "http://notes.it-jobs-und-stellen.de" | |
require 'bundler/capistrano' | |
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path. | |
require "rvm/capistrano" # Load RVM's capistrano plugin. | |
require 'capistrano_colors' | |
load "deploy/assets" | |
set :application, "Empfehlungsbund.de" | |
set :repository, "file:///home/stefan/repos/empfehlungsbund" | |
set :local_repository, "file://." | |
set :rvm_ruby_string, '1.9.2' # Or whatever env you want it to run in. | |
# https://github.com/capistrano/capistrano/issues/79 | |
set :normalize_asset_timestamps, false | |
set :scm, :git | |
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` | |
role :web, "localhost" # Your HTTP server, Apache/etc | |
role :app, "localhost" # This may be the same as your `Web` server | |
role :db, "localhost", :primary => true # This is where Rails migrations will run | |
set :deploy_to, TARGET_PATH | |
set :use_sudo, false | |
# passenger specific | |
namespace :deploy do | |
task :start do ; end | |
task :stop do ; end | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" | |
run "curl --silent #{TARGET_URL} > /dev/null" # push passenger | |
end | |
end | |
task :setup, :roles => [:app, :db, :web] do | |
run <<-CMD | |
mkdir -p -m 775 #{release_path} #{shared_path}/system #{shared_path}/db && | |
mkdir -p -m 777 #{shared_path}/log && | |
mkdir -p -m 777 #{shared_path}/db && | |
touch #{shared_path}/db/production.sqlite3 | |
CMD | |
end | |
after "deploy:setup", :setup_shared | |
task :symlink_db do | |
run "ln -nfs #{shared_path}/db/production.sqlite3 #{release_path}/db/production.sqlite3" | |
end | |
desc "set dir/file access rights" | |
task :configure do | |
run "chown -R www-data #{TARGET_PATH}" | |
run "chown -R www-data #{release_path}" | |
run "chown -R www-data #{shared_path}/log" | |
run "chown -R www-data #{release_path}/public/" | |
run "chown -h www-data #{TARGET_PATH}/current" | |
end | |
if USE_SPHINX | |
require 'thinking_sphinx/deploy/capistrano' | |
# Thinking Sphinx typing shortcuts | |
namespace :ts do | |
task :conf do | |
thinking_sphinx.configure | |
end | |
task :in do | |
thinking_sphinx.index | |
end | |
task :start do | |
thinking_sphinx.start | |
end | |
task :stop do | |
thinking_sphinx.stop | |
end | |
task :restart do | |
thinking_sphinx.restart | |
end | |
task :rebuild do | |
thinking_sphinx.rebuild | |
end | |
end | |
# http://github.com/jamis/capistrano/blob/master/lib/capistrano/recipes/deploy.rb | |
# :default -> update, restart | |
# :update -> update_code, symlink | |
namespace :deploy do | |
desc "Link up Sphinx's indexes." | |
task :symlink_sphinx_indexes, :roles => [:app] do | |
run "ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx" | |
end | |
task :activate_sphinx, :roles => [:app] do | |
thinking_sphinx.stop | |
symlink_sphinx_indexes | |
thinking_sphinx.configure | |
end | |
end | |
#after 'deploy:update_code', 'thinking_sphinx:stop' | |
after 'deploy:update_code', 'deploy:activate_sphinx' | |
after 'deploy:update_code', 'ts:start' | |
end | |
after "deploy:update_code", :symlink_db | |
before "deploy:symlink", :configure | |
after "deploy:symlink", :configure # symlink ownership! | |
before "deploy:migrate", :symlink_db | |
after 'bundle:install', 'deploy:migrate' | |
after "deploy", "deploy:cleanup" | |
# Cronjobs | |
if USE_WHENEVER | |
set :whenever_command, "bundle exec whenever" | |
require "whenever/capistrano" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment