2013-02-23 36 views
13

Tôi đang cố gắng để triển khai ứng dụng của tôi và tôi tiếp tục nhận đượctài sản Capistrano giết chết: precompile

*** [err :: xxx.xxx.xx.xxx] bash: line 1: 9953 Killed     bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile 

Tôi nghĩ vấn đề là quá trình này là dùng quá lâu. Không có lỗi trong nhật ký và top không hiển thị bất kỳ điều gì bất thường. Những gì tôi đã làm để thoát ra khỏi nhật ký là quá trình mà nó giết chết dường như là biên dịch application.js.

Khi tôi chạy rake assets:precompile cục bộ, không có lỗi/cảnh báo.

Tôi có thể gia hạn độ dài mà capistrano chờ trước khi giết quá trình không? Đó thực sự là vấn đề? Tôi có thể tìm ở đâu khác?

Cập nhật

khi chạy

bundle exec rake assets:precompile RAILS_ENV=production RAILS_GROUPS=assets --trace 

tôi nhận được kết quả như sau

** Invoke assets:precompile (first_time) 
** Execute assets:precompile 
** Invoke assets:precompile:all (first_time) 
** Execute assets:precompile:all 
** Invoke assets:precompile:primary (first_time) 
** Invoke assets:environment (first_time) 
** Execute assets:environment 
** Invoke tmp:cache:clear (first_time) 
** Execute tmp:cache:clear 
** Execute assets:precompile:primary 
Killed 

khi tôi chạy

bundle exec rake assets:precompile RAILS_ENV=production --trace 

tôi nhận được

** Execute tài sản: precompile

.../.rvm/rubies/ruby-1.9.3-p374/bin/ruby path/to/app/production/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace 

** Invoke assets:precompile:all (first_time) 

** Execute assets:precompile:all 

** Invoke assets:precompile:primary (first_time) 

** Invoke assets:environment (first_time) 

** Execute assets:environment 

** Invoke tmp:cache:clear (first_time) 

** Execute tmp:cache:clear 

** Execute assets:precompile:primary 

rake aborted! 

Command failed with status(): [/home/user/.rvm/rubies/ruby-1.9.3-p374...] 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `block in create_shell_runner' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `call' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `sh' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `sh' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils.rb:80:in `ruby' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `ruby' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/sprockets/assets.rake:12:in `ruby_rake_task' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `call' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `each' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain' 

/home/user/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `each' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `run' 

path/to/app/production/shared/bundle/ruby/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>' 

path/to/app/production/shared/bundle/ruby/1.9.1/bin/rake:23:in `load' 

path/to/app/production/shared/bundle/ruby/1.9.1/bin/rake:23:in `<main>' 

Tasks: TOP => assets:precompile 

này không xảy ra trong thư mục dàn dựng. Tôi cảm thấy như nó đang nhìn chằm chằm vào mặt tôi

+0

điều gì sẽ xảy ra khi bạn chạy cùng một lệnh trực tiếp trên máy chủ? hoặc bạn có nghĩa là khi bạn nói "cục bộ"? –

+0

btw. Tôi giả sử bạn đang sử dụng mặc định 'load 'deploy/assets'' gọi trong Capfile của bạn? –

+0

Tôi đang sử dụng tải 'triển khai/tài sản' gọi trong capfile của tôi và nhận được lỗi này trên một trong các máy chủ Linux của chúng tôi – HelloWorld

Trả lời

17

Vì vậy, tôi nghĩ rằng vấn đề của chúng tôi là bootstrap-sass là một phần của quá trình biên dịch tài sản. Vì vậy, nó đã thổi lên tất cả các css, và sau đó biên dịch tất cả xuống. Khi điều này được kết hợp với rất nhiều sass/css, quá trình sử dụng tấn bộ nhớ, và hệ điều hành sẽ giết nó. Sau nhiều nghiên cứu, tôi bắt gặp một giải pháp khá tốt. Biên dịch cục bộ, nén nó, tải lên, giải nén nó trên máy chủ, liên kết nó trên máy chủ, và sau đó xóa tất cả các tệp phụ đã được tạo (nội dung cục bộ/tệp nén).

Dưới đây là kịch bản

namespace :deploy do 
    namespace :assets do 

    task :precompile, :roles => :web do 
     from = source.next_revision(current_revision) 
     if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ lib/assets/ app/assets/ | wc -l").to_i > 0 
     run_locally("RAILS_ENV=#{rails_env} rake assets:clean && RAILS_ENV=#{rails_env} rake assets:precompile") 
     run_locally "cd public && tar -jcf assets.tar.bz2 assets" 
     top.upload "public/assets.tar.bz2", "#{shared_path}", :via => :scp 
     run "cd #{shared_path} && tar -jxf assets.tar.bz2 && rm assets.tar.bz2" 
     run_locally "rm public/assets.tar.bz2" 
     run_locally("rake assets:clean") 
     else 
     logger.info "Skipping asset precompilation because there were no asset changes" 
     end 
    end 

    task :symlink, roles: :web do 
     run ("rm -rf #{latest_release}/public/assets && 
      mkdir -p #{latest_release}/public && 
      mkdir -p #{shared_path}/assets && 
      ln -s #{shared_path}/assets #{latest_release}/public/assets") 
    end 
    end 

    # other stuff... 

end 

Dưới đây là where I found the script. Nó cung cấp một lời giải thích tốt hơn

Sửa:

Có một vấn đề với đường ray triển khai mới hơn. Tôi không chắc chắn phiên bản chính xác, nhưng nó dường như ảnh hưởng đến đường ray 4. Các tài sản cần phải xác định những gì môi trường họ đang được biên soạn cho, nếu không các môi trường sản xuất/dàn sẽ không tìm thấy chúng.

+0

@HelloWorld, đã làm việc này cho bạn? –

+0

vấn đề đằng sau này như bạn đã đề cập là không đủ RAM + bootstrap. Vì tôi vừa gặp sự cố này trên một trong các máy chủ thử nghiệm của mình, tôi chỉ chuyển máy chủ đó sang chế độ dev vì tôi muốn biên dịch các nội dung trên máy chủ bằng cách sử dụng capistrano.Tôi đã không thử câu trả lời của bạn nhưng tôi giả sử nó hoạt động và có thể là một công việc hữu ích xung quanh. Cảm ơn bạn đã đăng bài này và tôi đã +1 câu trả lời. – HelloWorld

+1

Cảm ơn Peter kịch bản này đã làm việc một say mê, cắt giảm thời gian triển khai của tôi từ vài phút đến vài giây. –

Các vấn đề liên quan