Skip to content

Commit

Permalink
Some handy tasks and config defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
markjaquith committed May 25, 2012
1 parent 374b85b commit 6ad6e06
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions Capistrano/Capfile
@@ -1,4 +1,5 @@
require 'rubygems'
require 'railsless-deploy'
load 'config/lib/misc'
load 'config/lib/tasks'
load 'config/deploy'
4 changes: 4 additions & 0 deletions Capistrano/config/SAMPLE.config.rb
Expand Up @@ -5,4 +5,8 @@
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

# Using Git Submodules?
set :git_enable_submodules, 1
if git_enable_submodules then before "deploy", "git:submodule_tags"

role :web, "your web-server here"
13 changes: 11 additions & 2 deletions Capistrano/config/deploy.rb
@@ -1,4 +1,13 @@
# Pull in the config file
loadFile 'config/config.rb'
#
set :user, "deploy"
set :use_sudo, false
set :deploy_via, :remote_cache
set :copy_exclude, [".git", ".gitmodules", ".DS_Store", ".gitignore"]
set :keep_releases, 5

after "deploy:restart", "deploy:cleanup"
after "deploy:update_code", "shared:make_shared_dir"
after "deploy:update_code", "shared:make_symlinks"

# Pull in the config file
loadFile 'config/config.rb'
30 changes: 30 additions & 0 deletions Capistrano/config/lib/tasks.rb
@@ -0,0 +1,30 @@
namespace :shared do
task :make_shared_dir do
run "if [ ! -d #{shared_path}/files ]; then mkdir #{shared_path}/files; fi"
end
task :make_symlinks do
run "if [ ! -h #{release_path}/shared ]; then ln -s #{shared_path}/files/ #{release_path}/shared; fi"
run "for p in `find -L #{release_path} -type l`; do t=`readlink $p | grep -o 'shared/.*$'`; sudo mkdir -p #{release_path}/$t; sudo chown www-data:www-data #{release_path}/$t; done"
end
end

namespace :nginx do
desc "Restarts nginx"
task :restart do
run "sudo /etc/init.d/nginx restart"
end
end

namespace :phpfpm do
desc" Restarts PHP-FPM"
task :restart do
run "sudo /etc/init.d/php-fpm restart"
end
end

namespace :git do
desc "Updates git submodule tags"
task :submodule_tags do
run "if [ -d #{shared_path}/cached-copy/ ]; then cd #{shared_path}/cached-copy/ && git submodule foreach --recursive git fetch origin --tags; fi"
end
end

0 comments on commit 6ad6e06

Please sign in to comment.