Деплой тормозит и виснет (Capistrano)

190 views
Skip to first unread message

Iliya S.

unread,
Oct 25, 2013, 1:37:15 PM10/25/13
to ror...@googlegroups.com
Всем привет.
"rake assets:precompile" и "cap deploy" внезапно стали отжирать по очень многу времени (час и более). В некоторых случаях деплой вообще виснет (ждал сутки).
Использую Rails 3.2.13, Ruby 1.9.3, OSX и Backbone's Chaplin Framework на фронтенде.
Пожалуйста, посоветуйте что тут можно предпринять - как ускорить деплой и прекомпил ассетов (удалённый деплой виснет и тормозит именно на прекомпиле удалённом, но и локальный прекомпил тоже не многим быстрее).

Подозреваю, может быть дело в конфиге настройках деплоя?
Вот мой конфиг deploy.rb:
# -*- encoding : utf-8 -*-
require 'bundler/capistrano'
load 'deploy/assets'
set :application, "eyelashes"
set :rails_env, "production"
set :repository,  "g...@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

Помогите, как мне ускорить деплой и избавиться от зависаний?

Alexander Timofeev

unread,
Oct 26, 2013, 12:06:53 AM10/26/13
to ror...@googlegroups.com
А вы проверьте размер скомпилированных файлов, на 90% уверен, много интересного для себя узнаете. И о себе от пользователей могли бы узнать ). У меня была похожая ситуация, случайно зациплился инклюд компонентов Бутстрапа, в рузльтате все компилировалось по полчаса.

суббота, 26 октября 2013 г., 0:37:15 UTC+7 пользователь Iliya S. написал:

Alex

unread,
Oct 26, 2013, 4:08:57 AM10/26/13
to ror...@googlegroups.com
Еще такая была история с гемом ckeditor - зацепился и компилился два раза.

Было реально долго, но не сутки.

Вам поможет провести диганостику параметр в deploy.rb:

set :bundle_flags, "--verbose"

и будет видно что у вас так долго.


2013/10/26 Alexander Timofeev <re.ti...@gmail.com>

--
--
Данное сообщение отправлено Вам, так как Вы являетесь подписчиком группы "RubyOnRails to russian" на https://groups.google.com/group/ror2ru
FAQ группы находится по адресу: http://ru.wikibooks.org/wiki/RubyFAQ
 
Для того, чтобы отправить сообщение в эту группу, пошлите его по адресу
ror...@googlegroups.com
---
Вы получили это сообщение, поскольку подписаны на группу RubyOnRails to russian.
 
Чтобы отказаться от подписки на эту группу и перестать получать из нее сообщения, отправьте электронное письмо на адрес ror2ru+un...@googlegroups.com.
Просмотреть это обсуждение в Сети можно по адресу https://groups.google.com/d/msgid/ror2ru/c6aeca4f-cb13-4588-b17a-adca53943ea6%40googlegroups.com.

Настройки подписки и доставки писем: https://groups.google.com/groups/opt_out.

Iliya S.

unread,
Oct 26, 2013, 10:53:59 AM10/26/13
to ror...@googlegroups.com
К сожалению, public/assets (скомилированные ассеты) весят всего 23 мегабайта :(

суббота, 26 октября 2013 г., 6:06:53 UTC+2 пользователь Alexander Timofeev написал:
Reply all
Reply to author
Forward
0 new messages