Capistrano recipe for Merb 0.5.3 in production

Further to my article about God, and using it for watching Merb it seemed like a good idea that I also post my capistrano recipe so people can get the complete picture :)

# MIT License
# 
# Copyright (c) 2008, Tim Perrett
# 
# Permission is hereby granted, free of charge, to any person 
# obtaining a copy of this software and associated 
# documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, 
# and/or sell copies of the Software, and to permit persons 
# to whom the Software is furnished to do so, subject to the 
# following conditions:
# 
# The above copyright notice and this permission notice shall 
# be included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 
# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
# OR OTHER DEALINGS IN THE SOFTWARE.

set :application, "domain.com" 

set :repository, "svn://yourrepo.com/path/to/repo" 

# Set your SVN and SSH User
set :user, "sshuser" 
set :svn_user, "svnuser" 
#Set the full path to your application on the server
set :deploy_to, "/path/to/your/#{application}" 

# define your servers
role :app, "domain.com" 
role :web, "domain.com" 
role :db, "domain.com", :primary => true

desc "Link in the production extras" 
task :after_update_code do
  run "ln -nfs #{shared_path}/log #{release_path}/log" 
end

desc "Merb it up with" 
deploy.task :restart do
  # you need to add restart tasks for each port you plan 
  # to run merb on. Whilst this is a little long winded, 
  # it will ensure uptime compared to the sledge hammer
  # than is #{current_path}/script/stop_merb
  run "(cd #{current_path}; merb -k 4006); sleep 1; \
  #{current_path}/script/merb -u timperrett -G timperrett \
  -M #{current_path}/config/merb.yml -p 4006 \
  -e production -d" 
  run "(cd #{current_path}; merb -k 4007); sleep 1; \
  #{current_path}/script/merb -u timperrett -G timperrett \
  -M #{current_path}/config/merb.yml -p 4007 \
  -e production -d" 
end

Any problems, let me know :)

comments powered by Disqus