代码之家  ›  专栏  ›  技术社区  ›  Yuval Karmi

为乘客部署Rails应用程序的最快方式

  •  4
  • Yuval Karmi  · 技术社区  · 14 年前

    我在使用Rails 2.3.5的DreamHost服务器上工作。

    每次我对一个站点进行更改时,我都必须ssh到该站点,删除所有文件,上载一个包含该站点所有新文件的zip文件,解压缩该文件,迁移数据库,然后离开。

    有东西告诉我有一种更快的部署Rails应用程序的方法。我正在使用Mac Time Machine跟踪我的应用程序的不同版本。我知道Git跟踪文件,但我真的不知道如何使用它来部署我的应用程序,因为Passenger为我提供了所有的魔力。

    部署应用程序的更快方法是什么(并避免在删除服务器上的所有文件时与我的方法相关联的停机时间)?

    谢谢!

    3 回复  |  直到 14 年前
        1
  •  1
  •   shashin    14 年前

    去给自己找些Capistrano帮手: http://github.com/westarete/capistrano-helpers

    这是我自己站点的一个简化的、带注释的部署文件。

    require 'capistrano-helpers/branch'     # prompts for branch
    require 'capistrano-helpers/passenger'  # Support for Apache passenger
    require 'capistrano-helpers/version'    # Record the version number after deploying
    require 'capistrano-helpers/privates'   # handle sensitive files
    require 'capistrano-helpers/shared'
    
    set :application, "site"
    set :repository,  "file://."
    
    set :scm, "git"
    set :branch, "rails3"
    set :deploy_via, :copy
    
    set :copy_exclude, [ ".git", "assets", "test", "Capfile", "vishvish.tmproj", "bin" ]
    
    set :deploy_to, "/blah/blah.com/#{application}"
    
    set :user, "blah"
    set :domain, "blah.com"
    
    #Things you want symlinked afterwards, not in version control.
    set :privates, %w{
      config/database.yml
    }
    
    #Things you want shared across deployments, not uploaded every time.
    set :shared, %w{
      uploads
    }
    
    role :app, domain
    role :web, domain
    role :db,  domain, :primary => true
    
    namespace :deploy do
      desc "Restarting mod_rails with restart.txt"
      task :restart, :roles => :app, :except => { :no_release => true } do
        run "touch #{current_path}/tmp/restart.txt"
      end
    
      [:start, :stop].each do |t|
        desc "#{t} task is a no-op with mod_rails"
        task t, :roles => :app do ; end
      end
    end
    
        2
  •  4
  •   Corey    14 年前

    看看 Capistrano .

        3
  •  1
  •   Toby Hede    14 年前

    你肯定需要吉特和卡皮斯特拉诺。

    我的部署过程:

    git commit
    git push
    cap deploy
    

    Git非常直截了当。Github.com上有大量的资源和操作方法。 如果您不使用源代码管理,您必须修复它…