2012-01-18 66 views
2

我不確定問題的確切位置,但Capistrano需要大約5分鐘才能部署一個幾乎空的項目。卡皮斯特拉諾很慢

你能告訴我如果我做錯了什麼或是平時的事情嗎?

我使用:

  • Capistrano的2.9.0
  • 的Rails 3.1.3
  • Github上庫
  • 不是太慢服務器(4個核心,1個GB內存)
  • ngix,乘客

這裏是我得到的輸出: https://gist.github.com/1632009

Capfile

load 'deploy' if respond_to?(:namespace) # cap2 differentiator 
# Uncomment if you are using Rails' asset pipeline 
load 'deploy/assets' 
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } 
load 'config/deploy' # remove this line to skip loading any of the default tasks 

deploy.rb

# -*- encoding : utf-8 -*- 
require "bundler/capistrano" 

set :user, 'rubys' 
set :domain, 'example.com' 
set :application, 'EXAMPLE' 

# adjust if you are using RVM, remove if you are not 
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) 
require "rvm/capistrano" 
set :rvm_ruby_string, '1.9.2' 
#set :rvm_type, :user 

# file paths 
set :repository, "[email protected]:GITHUBREPO/ashop.git" 
set :deploy_to, "/apps/#{application}" 

# using a local git repository on the server you are deploying to. 
set :deploy_via, :remote_cache 
set :copy_exclude, [ '.git' ] 


# distribute your applications across servers (the instructions below put them 
# all on the same server, defined above as 'domain', adjust as necessary) 
role :app, domain 
role :web, domain 
role :db, domain, :primary => true 


set :deploy_via, :remote_cache 
set :scm, 'git' 
set :branch, 'master' 
set :scm_verbose, false 
set :use_sudo, false 
set :rails_env, :production 

namespace :deploy do 
    desc "cause Passenger to initiate a restart" 
    task :restart do 
    run "touch #{current_path}/tmp/restart.txt" 
    end 
end 

編輯

+0

是網絡速度慢? – 2012-01-18 08:42:11

+0

5Mbit理論上傳/下載http://www.speedtest.net/result/1714391142.png – Mark 2012-01-18 08:43:45

+0

服務器可能<=> github很慢 – 2012-01-18 08:45:05

回答

1

Capistrano的是可能是一堆理由緩慢。一個是它會在您的deploy.rb文件中爲每個run打開一個新的遠程shell到您的服務器。

這可以通過使用ssh主通道修改一下,這會導致capistrano實際重用ssh連接,這意味着更少的網絡開銷。

這裏有紅寶石部署了一篇文章,提到SSH主渠道:http://alexyoung.org/2011/05/17/deployment/

另一個原因是,它複製你的整個代碼庫爲每部署一個新的目錄。

此使用Git時不是嚴格必要的,github上,對如何「修理」一個精彩的文章這樣的:https://github.com/blog/470-deployment-script-spring-cleaning

+0

隨着主通道的部署速度提高了一點點。稍後我會嘗試第二種解決方案。 – Mark 2012-01-18 11:28:49

+1

無論使用.ssh/config中的主通道配置如何,Capistrano似乎都會重用其SSH連接。 – Zr40 2012-04-01 17:51:30

+0

我注意到使用主通道時沒有區別。當我手動SSH連接到我的服務器時,併發連接要快得多,但Capistrano似乎並不在乎。 – Ciryon 2014-12-21 22:41:10