簡體   English   中英

Capistrano:KILL RAILS_ENV =生產RAILS_GROUPS =資產捆綁執行rake資產:預編譯

[英]Capistrano: Killed RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile

整個昨天下午,我正在處理這個問題,我找到了這個主題,這對我來說沒有用。

然后我在SO上找到了一個主題,在那里給出了一個建議,將load 'deploy/assets'Capfile 最后,它奏效了!

但是今天早上當我嘗試部署另一個代碼時,我又得到了這個錯誤:

 ** [out :: IP] bash: line 1: 15213 Killed                  RAILS_ENV=staging RAILS_GROUPS=assets bundle exec rake assets:precompile
    command finished in 38500ms
*** [deploy:update_code] rolling back

我讓我發瘋,昨天一切都很好,但今天 - 突然間 - 再次出現同樣的錯誤。 這是我的設置:

Capfile:

load 'deploy'
load 'config/deploy' # remove this line to skip loading any of the default tasks
load 'deploy/assets'

部署/ production.rb:

...
namespace :deploy do

  task :setup_config, roles: [:app] do
    sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/app"
    sudo "ln -nfs #{current_path}/config/unicorn_init_production.sh /etc/init.d/unicorn_app-production"
    run "mkdir -p #{shared_path}/config"
    put File.read("config/database.yml"), "#{shared_path}/config/database.yml"
    puts "Now edit the config files in #{shared_path}."
  end
  after "deploy:setup", "deploy:setup_config"

  task :symlink_config, roles: [:app] do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  end
  after "deploy:finalize_update", "deploy:symlink_config"
  after "deploy:create_symlink", "deploy:restart"

  desc "Make sure local git is in sync with remote."
  task :check_revision, roles: [:web] do
    unless `git rev-parse HEAD` == `git rev-parse origin/master`
      puts "WARNING: HEAD is not the same as origin/master"
      puts "Run `git push` to sync changes."
      exit
    end
  end
  %w[stop].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      run "/etc/init.d/unicorn_app-production #{command}"
    end
  end


  %w[restart].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      run "/etc/init.d/unicorn_app-production #{command}"
    end
  end

  before "deploy", "deploy:check_revision"  
end

deploy.rb:

require "capistrano/ext/multistage"
require "rvm/capistrano"
require 'bundler/capistrano'
require 'delayed/recipes' # added for running deplayed jobs

set :application, 'app'
set :bundle_flags, "--quiet --no-cache"

set :scm, :git
default_run_options[:pty] = true
set :deploy_via, :remote_cache
set :repository, 'git@bitbucket.org:name/repo.git'
set :branch, "master"
set :pty, true
set :keep_releases, 5

我會對每一個建議都非常有幫助!

感謝大伙們

編輯:環境/ production.rb

App::Application.configure do
  config.cache_classes = true
  config.eager_load = true

  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = true

  config.assets.js_compressor = :uglifier
  config.assets.css_compressor = :sass

  config.assets.compile = false
  config.assets.precompile = ['*.js', 'application.css', 'styles.css.scss', '*.css.erb']
  config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif *.svg *.woff *.ttf *.ico)
  config.assets.digest = true
  config.assets.version = '1.2'
  config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
  config.log_level = :info
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.log_formatter = ::Logger::Formatter.new
  config.action_mailer.default_url_options = { :host => 'http://www.app.com' }
end

服務器終止進程,查看服務器上的dmesg ,我認為你沒有內存進行編譯。 dmesg返回:

[5689488.101760]內存不足:殺死進程31427(ruby)得分184或犧牲孩子[5689488.102528]被殺死的進程31427(ruby)total-vm:948244kB,anon-rss:235856kB,file-rss:0kB

您可以編譯資產localy並移動到服務器,而無需升級內存。

看看這個gist還是這個gem

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM