【问题标题】:Rails app deployment with capistrano Killing assets precompile使用 capistrano Killing 资产预编译的 Rails 应用程序部署
【发布时间】:2013-04-29 23:54:48
【问题描述】:

on cap deploy:cold ro cap deploy,触发错误

[out :: xxx.xxx.xxx.xxx] Killed
command finished in 9020ms
*** [deploy:update_code] rolling back
* executing [#<Capistrano::Command::Tree::ElseBranch:0x00000100dc5478 @condition="else", @command="rm -rf /home/yasinishyn/apps/mkv/releases/20130506084016; true", @callback=#<Proc:0x00000100dd5da0@/usr/local/rvm/gems/ruby-2.0.0-p0/gems/capistrano-2.15.3/lib/capistrano/configuration/actions/invocation.rb:13>, @options={}, @skip=false>]
servers: ["xxx.xxx.xxx.xxx"]
[xxx.xxx.xxx.xxx] executing command
command finished in 386ms
failed: "sh -c 'cd -- /home/yasinishyn/apps/mkv/releases/20130506084016 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on xxx.xxx.xxx.xxx

我从堆栈中尝试了许多建议,但嗅探对我有用。

我的 deploy.rb

部署.rb:

require "bundler/capistrano" 

server "xxx.xxx.xxx.xxx", :web, :app, :db, primary: true

set :application, "app" 
set :user, "user" 
set :deploy_to, "/home/#{user}/apps/#{application}" 
set :deploy_via, :remote_cache 
set :use_sudo, false

set :scm, "git" 
set :repository, "git@github.com:git_user/#{application}.git" 
set :branch, "master"

default_run_options[:pty] = true 
ssh_options[:forward_agent] = true


after "deploy", "deploy:cleanup" # keep only the last 5 releases

namespace :deploy do 

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

task :setup_config, roles: :app do 
    sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}" 
    sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}" 
    run "mkdir -p #{shared_path}/config" 
    put File.read("config/database.example.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"
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 
before "deploy", "deploy:check_revision" 
#rake seed task
desc "Seed the database on already deployed code"
task :seed, :only => {:primary => true}, :except => { :no_release => true } do
    run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake db:seed"
end
desc "Seed the database on already deployed code"
task :drop, :only => {:primary => true}, :except => { :no_release => true } do
    run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake db:drop:all"
    run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake db:create:all"
    run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake db:migrate"
end
end

在我的 production.rb 我有

config.assets.compress = true

还有我的capfile

load 'deploy'
# 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

使用“bundle exec rake assets:precompile RAILS_ENV=production --trace”进行本地预编译不会出现任何错误。

我的错误在哪里?热调试吗?或者也许某个地方有一些 capistano 的日志文件,可以在其中查找更多详细信息?

【问题讨论】:

  • 尝试在服务器上运行命令。
  • 没有发布,因为它是初始上限部署:冷

标签: ruby-on-rails ruby deployment capistrano asset-pipeline


【解决方案1】:

我自己找到答案

从 capfile 中删除“load 'deploy/assets'”,然后运行

cap deploy:cold

这将在没有错误的情况下工作,但仅限于初始部署。然后像往常一样在服务器上“sudo service nginx restart”,并添加回删除的sn-p。

And BAMM!! It works :)

【讨论】:

    【解决方案2】:

    你的内存已经用完了,这个问题和答案帮助了我 - 我增加了数字海洋服务器上的交换,一切正常:deploy with capistrano failing

    【讨论】:

      【解决方案3】:

      对于遇到同样问题且 Andrey 回答不起作用的任何人,请停止服务器“sudo service nginx stop”,然后进行 cap deploy,然后再次启动服务器“sudo service nginx start”。它对我有用。

      【讨论】:

        猜你喜欢
        • 2012-02-19
        • 2014-02-05
        • 1970-01-01
        • 2013-11-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多