0
votes

on cap deploy:cold ro cap deploy, is triggered an error

[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

I have tryed many advises from stack, but nosing works for me.

my deploy.rb

deploy.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

in my production.rb I have

config.assets.compress = true

and my 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

local precompile with "bundle exec rake assets:precompile RAILS_ENV=production --trace" executes without any errors.

Where is my mistake? Hot to debug it? Or maybe somewhere is some log file for capistano in which a can look for more details?

3
Try to run the command on the server.Mindbreaker
there are no releases because it was initial cap deploy:coldAndrey Yasinishyn

3 Answers

2
votes

I find an answer by my own

delete "load 'deploy/assets'" from capfile, and run

cap deploy:cold

this will work without an error, but only on initial deploy. Then as usual "sudo service nginx restart" on server, and add back deleted snippet.

And BAMM!! It works :)
1
votes

You are out of RAM by the sounds of it, this question and answer helped me out - I increased the swap on digital ocean server and everything worked fine: deploy with capistrano failing

0
votes

For anyone who face the same problem and Andrey answer don't work stop the server "sudo service nginx stop" then cap deploy and then start the server again "sudo service nginx start". It worked for me.