0

「rake assets:precompile」と「cap deploy」は、呼び出すたびに非常に長い時間を消費します (通常は 1 時間以上)。展開がまったくハングすることがあります。フロントエンドには Rails 3.2.13、Ruby 1.9.3、OSX、Backbone の Chaplin Framework を使用しています。アセットのプリコンパイルとデプロイのタスクを高速化するにはどうすればよいですか?また、そのようなフリーズを引き起こす原因は何ですか?

私の deploy.rb 設定:

# -*- encoding : utf-8 -*-
require 'bundler/capistrano'
load 'deploy/assets'

set :application, "eyelashes"
set :rails_env, "production"

set :repository,  "git@github.com:eyelasher/repo.git"
set :scm, :git
set :deploy_via, :checkout
set :ssh_options, { :forward_agent => true }
default_run_options[:pty] = true


server "75.223.145.3", :app, :web, :db, :primary => true

set :bundle_without,  [:test]

set :user, 'deployer'
set :deploy_to, "/home/deployer/eyelasher"
set :branch, "master" unless exists?(:branch)
set :use_sudo, false

set :rvm_type, :user
set :rvm_ruby_string, :local
set :deploy_via, :checkout
before 'deploy:setup', 'rvm:create_gemset'

set :unicorn_conf, "#{deploy_to}/current/config/unicorn.rb"
set :unicorn_pid, "#{deploy_to}/shared/pids/unicorn.pid"

after "deploy", "deploy:migrate"
after "deploy", "deploy:cleanup"

require 'rvm/capistrano'
require 'thinking_sphinx/deploy/capistrano'

#after 'deploy:update_code', :roles => :app do
  #run "rm -f #{current_release}/config/database.yml"
  #run "ln -s #{deploy_to}/shared/config/database.yml #{current_release}/config/database.yml"
#end

namespace :deploy do
  task :restart do
    run "if [ -f #{unicorn_pid} ]; then kill -USR2 `cat #{unicorn_pid}`; else cd #{deploy_to}/current && bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D; fi"
  end
  task :start do
    run "cd #{deploy_to}/current && bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D;"
  end
  task :stop do
    run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -QUIT `cat #{unicorn_pid}`; fi"
  end

end


# Thinking Sphinx typing shortcuts
namespace :ts do
  task :conf do
    thinking_sphinx.configure
  end
  task :in do
    thinking_sphinx.index
  end
  task :start do
    thinking_sphinx.start
  end
  task :stop do
    thinking_sphinx.stop
  end
  task :restart do
    thinking_sphinx.restart
  end
  task :rebuild do
    thinking_sphinx.rebuild
  end
end

# http://github.com/jamis/capistrano/blob/master/lib/capistrano/recipes/deploy.rb
# :default -> update, restart
# :update  -> update_code, symlink
namespace :deploy do
  desc "Link up Sphinx's indexes."
  task :symlink_sphinx_indexes, :roles => [:app] do
    run "ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx"
  end

  task :activate_sphinx, :roles => [:app] do
    symlink_sphinx_indexes
    thinking_sphinx.configure
    #thinking_sphinx.stop
    #thinking_sphinx.start
  end

  task :copy_images do
    run "cp -R #{shared_path}/public/images #{release_path}/public/images"
  end

  before 'deploy:update_code', 'thinking_sphinx:stop'
  after 'deploy:update_code', 'deploy:activate_sphinx'
  after 'deploy:update_code', 'deploy:copy_images'

end

展開構成を変更することで、何とかスピードアップできるでしょうか?

4

1 に答える 1

0

メモリに制約のある VPS に展開している場合は、もっともらしく聞こえます。より高速なマシンでアセットをプリコンパイルし、リポジトリにチェックインすることをお勧めします。

それらを並列処理することでアセットのプリコンパイルを高速化するためのさまざまな Gem とパッケージがありますが、状況がさらに悪化する可能性があります。

于 2013-10-25T17:13:26.350 に答える