My Sinatra+Capistrano+Capinatra deployment recipe

Ruby posted 11 months ago by christian

   1  require 'capistrano/version'
   2  require 'rubygems'
   3  require 'capinatra'
   4  load 'deploy' if respond_to?(:namespace) # cap2 differentiator
   5  
   6  # set an app_class if you're using the more recent style of creating
   7  # Sinatra apps, where app_class would be the name of your subclass
   8  # of Sinatra::Base. if you're just requiring 'sinatra' and using the
   9  # more traditional DSL style of Sinatra, then comment this line out.
  10  set :app_class, 'xxx'
  11  
  12  # standard settings
  13  set :app_file, "xxx.rb"
  14  set :application, "xxx"
  15  set :domain, "xxx.com"
  16  role :app, domain
  17  role :web, domain
  18  role :db,  domain, :primary => true
  19  
  20  set :ssh_options, { :forward_agent => true }
  21  
  22  #set :use_sudo, false
  23  
  24  # environment settings
  25  set :user, "xxx"
  26  set :group, "www-data"
  27  set :deploy_to, "/var/www/#{application}"
  28  set :deploy_via, :copy #:remote_cache
  29  default_run_options[:pty] = true
  30  
  31  # scm settings
  32  set :repository, "git@xxx.com:xxx.git"
  33  #set :repository, "file:///home/git/repositories/xxx.git"
  34  set :scm, "git"
  35  set :branch, "master"
  36  set :git_enable_submodules, 1
  37  
  38  # where the apache vhost will be generated
  39  set :apache_vhost_dir, "/etc/apache2/sites-enabled/"
  40  
  41  namespace :deploy do
  42    task :restart do
  43      run "touch #{current_path}/tmp/restart.txt"
  44    end
  45  end

Tagged capistrano, sinatra, capinatra