Karthick
Karthick

Reputation: 443

Capistrano 3 not deploy and show this error SSHKit::Command::Failed: rake stdout: Nothing written

I have used rails 4 and Capistrano 3. When i depoly with Capistrano fail during rake assets:precompile and show following error

 INFO [1c9c2531] Running ~/.rvm/bin/rvm default do bundle exec rake assets:precompile on 107.170.67.113
cap aborted!
SSHKit::Command::Failed: rake stdout: Nothing written
rake stderr: Nothing written

Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)

I'm newbie on rails and server setup so where am i missing.I don't know

Here my depoly.rb

SSHKit.config.command_map[:rake] ||= "bundle exec rake"

# config valid only for Capistrano 3.1
lock '3.0.1'


set :application, 'PCA'
set :repo_url, '[email protected]:3lackRos3/pca.git'

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call

# Default deploy_to directory is /var/www/my_app
 set :deploy_to, '/home/pca/app/pca'
 set :deploy_user, 'pca'

 set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
 set :rvm_type, :user
 set :rvm_bin_path, '/usr/local/rvm/bin'


#  set :default_environment, {
#   'RBENV_ROOT' => '/usr/local/rbenv',
#   'PATH' => "/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH"
# }

# set :default_environment, {
#   'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
# }
# set :rbenv_ruby, "2.1.1"

 #    set :rbenv_ruby_dir, -> { "#{fetch(:rbenv_path)}/versions/#{fetch(:rbenv_ruby)}" }
 #    set :rbenv_map_bins, %w{rake gem bundle ruby rails}
# Default value for :scm is :git
 set :scm, :git
 set :ssh_options, { forward_agent: true }
 #set :ssh_options, proxy: Net::SSH::Proxy::Command.new('ssh  [email protected]  -W %h:%p')

# Default value for :format is :pretty
# set :format, :pretty

set :log_level, :info
# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
set :pty, true


# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
 set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}




 # SSHKit.config.command_map[:rake].sub!(/\(.*\)rake/, "\1bundle exec rake")

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
# set :keep_releases, 20
after "deploy", "deploy:cleanup"

namespace :deploy do

  desc 'Restart application'
  task :restart do
#    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
#       execute :touch, release_path.join('tmp/restart.txt')
#    end
  end

  after :publishing, :restart

  after :restart, :clear_cache do
#    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
#    end
  end
 after :finishing, 'deploy:cleanup'
end

Here my capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'
#require 'rvm1/capistrano3'
#require 'capistrano/rvm'
# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#
require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
 require 'capistrano/bundler'
 require 'capistrano/rails/assets'
 require 'capistrano/rails/migrations'
 require 'capistrano/rails'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

I have run bundle exec cap production deploy:check and my output is

  INFO [ecf1a980] Running /usr/bin/env mkdir -p /tmp/PCA/
  INFO [ecf1a980] Finished in 4.848 seconds with exit status 0 (successful).
  INFO Uploading /tmp/PCA/git-ssh.sh 100.0%
  INFO [8e7210f6] Running /usr/bin/env chmod +x /tmp/PCA/git-ssh.sh on serverip
  INFO [8e7210f6] Finished in 0.639 seconds with exit status 0 (successful).
  INFO [4c538c51] Running /usr/bin/env mkdir -pv /home/pca/app/pca/shared /home/pca/app/pca/releases
 INFO [4c538c51] Finished in 4.480 seconds with exit status 0 (successful).
 INFO [d6a7dce6] Running /usr/bin/env mkdir -pv /home/pca/app/pca/shared/bin /home/pca/app/pca/shared/log /home/pca/app/pca/shared/tmp/pids /home/pca/app/pca/shared/tmp/cache /home/pca/app/pca/shared/tmp/sockets /home/pca/app/pca/shared/vendor/bundle /home/pca/app/pca/shared/public/system
 INFO [d6a7dce6] Finished in 4.507 seconds with exit status 0 (successful).

Anybody help me..

thanks!

Upvotes: 0

Views: 3492

Answers (3)

Moses Lucas
Moses Lucas

Reputation: 57

I have the same issue, having the error rake stderr: Nothing written when running (deployment) cap production deploy.

Turns out it's due to lack of memory, I have a 1G memory server, so "The Solution is to create a swap memory". For me, creating a 2G swap memory fixed it. Deployment now continues and finishes without any errors.

Upvotes: 2

MicRum
MicRum

Reputation: 1721

Seems like precompiling process killing due to the lack of memory. Try to create swap memory. Check out this tutorial

Upvotes: 1

Babar
Babar

Reputation: 1202

Make sure to include ssh key of server where deployment is occurring in gits trusted keys.

Upvotes: 0

Related Questions