capistrano

Deploying Drupal projects: git + capistrano

 

removing some folders from git, file .gitignore with these contents:

 

# Ignore paths that contain generated content.

cache/

files/

sites/*/files

sites/*/private

 

 

 

Using symbolic links for /files directory:

 

 

namespace:custom do

    task:symlink do

      run "ln -s /var/www/crucerista/sites/crucerista.net/files/ /var/www/crsta/current/sites/crucerista.net/"

      run "echo 'finished'"

    end

end

after "deploy","custom:symlink"

 

 

Related links:

Similar technique, but aplied to Rails apps: http://www.practicalecommerce.com/blogs/post/468-Creating-Symlinks-When-Deploying-a-Rails-Application

Another idea, File Transfer actions in Capistrano: http://www.simonecarletti.com/blog/2009/02/capistrano-uploads-folder/

 

Installing capistrano in Centos

Very very easy in CentOS, just like it would be in a Debian system:

# yum install ruby -y

# yum install rubygems -y

# gem install capistrano

Really, it couldn't be easier. Next step, just having fun with Capistrano :-)

categorias: 

Capistrano config.rb

set :application, "bounty app"

#set :repository,  "localhost:/var/www/git/bountyrepo"

set :repository,  "localhost:/var/www/git/blessed"


set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names

# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

#



default_run_options[:pty] = true

set :use_sudo, false


#role :web, "localhost"                          # Your HTTP server, Apache/etc

#role :app, "localhost"                          # This may be the same as your `Web` server

#role :db,  "your primary db-server here", :primary => true # This is where Rails migrations will run

#role :db,  "your slave db-server here"

#

#set :deploy_to, "/var/www/html/staging"



task :staging do

  role :web, "localhost"

  set :deploy_to, "/var/www/html/staging"

  #set :deploy_via, :remote_cache

  #after('deploy:symlink', 'cache:clear')

end

task :live do
  role :web, "localhost"
  set :deploy_to, "/var/www/html/live"
  #set :deploy_via, :remote_cache
  #after('deploy:symlink', 'cache:clear')
end
task :live2 do
  role :web, "localhost"
  set :deploy_to, "/var/www/html/live2"
  #set :deploy_via, :remote_cache
  #after('deploy:symlink', 'cache:clear')
end
# if you're still using the script/reaper helper you will need
# If you are using Passenger mod_rails uncomment this:
# 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')}"
#   end
# end
#
#
namespace:deploy do
    task:start do
    end
    task:stop do
    end
    task:finalize_update do
        run "chmod -R g+w #{release_path}"
    end
    task:restart do
    end
 after "deploy:restart" do
   #add any tasks in here that you want to run after the project is deployed
     run "rm -rf #{release_path}.git"
  end
end

 

categorias: