capistrano

    Upgrade to capistrano3

    02 Nov 2013

    New things

    I updated capistrano from 2.x to 3.0 for one project, it was a huge change. The followings are the new things:

    1. New structure. If you use capify to generate base structure, you will see some new syntax.

    In Capfile, you need to require all dependencies/plugins you need for deployment.

    require 'capistrano/setup'
    require 'capistrano/deploy'
    
    require 'capistrano/rvm'
    require 'capistrano/bundler'
    require 'capistrano/rails'
    
    Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
    ... Read More

    Tags 


    speed up git deployment with depth 1

    14 Sep 2012

    By default, when you deploy your application by capistrano git, it will clone the repository with entire history on production server, but it's meaningless. You should never go to production host and check git log, instead you just need latest code on production host.

    With your application grows, git clone with entire history may take a bit longer time than you expected. The following is the time spent with fully cloning.

    $ time git clone g...
    Read More

    Tags 


    git for hostmonster

    02 May 2010

    前段时间对网站做了些更新,于是在本地修改了代码,再git push,谁知却得到bash: git-receive-pack: command not found的error,我的git repository是放在hostmonster服务器上面的,之前都是正常的,于是提交ticket给hostmonster的support,得到的答复是他们升级的openssh,通过git+ssh不会再读取.bashrc或.ssh/environment文件,也就是说通过git+ssh没有办法修改PATH了。

    没办法了,只能手动将命令的路径补全了,对于git pull/git ps来说,只需要在输入命令的时候增加参数,比如

    git clone --upload-pack=/home1/huangzhi/git/bin/git-upload-pack
    git push --receive-pack=/home1/huangzhi/git/bin/git-receive-pack

    不过每次都输入参数实在麻烦,直接写到配置文件.git/config

    [remote "origin"]
    uploa...
    Read More

    Tags 


    capistrano读取releases目录的错误

    04 Jan 2010

    新年刚开始工作就遇到capistrano读取releases目录的错误,deploy之后总是把最新的release目录删除,看来是判断哪个release目录是最新的时候出错了。

    看了下2.5.11源代码,capistrano是这样定义releases目录的

    _cset(:releases)          { capture("ls -x #{releases_path}").split.reverse }

    其中ls -x的结果是

    20091224074632  20091228080936  20091228082551  20100104023017  20100104025008

    也就是说releases的结果就是

    ['20100104025008', '20100104023017', '20091228082551', '20091228080936', '20091224074632']

    再看看删除release部分的代码

    directories = (releases - releases.last(count)).map { |release|
      ...
    Read More

    Tags 


    通过Capistrano部署Rails App到Hostmonster

    06 Jun 2009

    贴贴我通过Capistrano自动发布到Hostmonster的deploy.rb文件吧

    set :application, "huangzhimin.com"
    set :repository,  "GIT_REPOSITORY"
    set :user, "huangzhi"
    set :scm, :git
    set :deploy_to, "DEPLOY_DIRECTORY"
    
    role :app, "www.huangzhimin.com"
    role :web, "www.huangzhimin.com"
    role :db,  "www.huangzhimin.com", :primary => true
    
    set :use_sudo, false
    set :run_method, :run
    
    namespace(:deploy) do
      task :after_update_code, :roles => :app do
        run "ln -s #{shared_path}/config/database.yml #{current_release}/config/da...
    Read More

    Tags