I am using a digital ocean server to which I had already deployed successfully a few times. Suddenly, whenever I run cap production deploy
it fails and tells me there are missing gems, some of which are in the development group so they shouldn't even be in production. Here is my console output with the missing gems. There are also some failed processes that seem to be related to the assets precompile.
DEBUG [c182dc11] Running [ -L /home/deploy/apps/team_hadley/releases/20161105191648/public/assets ] on 162.243.135.130
DEBUG [c182dc11] Command: [ -L /home/deploy/apps/team_hadley/releases/20161105191648/public/assets ]
DEBUG [c182dc11] Finished in 0.062 seconds with exit status 1 (failed).
DEBUG [5bd74104] Running [ -d /home/deploy/apps/team_hadley/releases/20161105191648/public/assets ] on 162.243.135.130
DEBUG [5bd74104] Command: [ -d /home/deploy/apps/team_hadley/releases/20161105191648/public/assets ]
DEBUG [5bd74104] Finished in 0.064 seconds with exit status 1 (failed).
INFO [92c16c38] Running /usr/bin/env ln -s /home/deploy/apps/team_hadley/shared/public/assets /home/deploy/apps/team_hadley/releases/20161105191648/public/assets on 162.243.135.130
DEBUG [92c16c38] Command: /usr/bin/env ln -s /home/deploy/apps/team_hadley/shared/public/assets /home/deploy/apps/team_hadley/releases/20161105191648/public/assets
INFO [92c16c38] Finished in 0.061 seconds with exit status 0 (successful).
DEBUG [7012f1eb] Running if test ! -d /home/deploy/apps/team_hadley/releases/20161105191648; then echo "Directory does not exist '/home/deploy/apps/team_hadley/releases/20161105191648'" 1>&2; false; fi on 162.243.135.130
DEBUG [7012f1eb] Command: if test ! -d /home/deploy/apps/team_hadley/releases/20161105191648; then echo "Directory does not exist '/home/deploy/apps/team_hadley/releases/20161105191648'" 1>&2; false; fi
DEBUG [7012f1eb] Finished in 0.065 seconds with exit status 0 (successful).
DEBUG [d02096e8] Running ~/.rvm/bin/rvm default do bundle check --path /home/deploy/apps/team_hadley/shared/bundle on 162.243.135.130
DEBUG [d02096e8] Command: cd /home/deploy/apps/team_hadley/releases/20161105191648 && ~/.rvm/bin/rvm default do bundle check --path /home/deploy/apps/team_hadley/shared/bundle
DEBUG [d02096e8] ESC[32mRVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
DEBUG [d02096e8]
DEBUG [d02096e8] you can ignore these warnings with 'rvm rvmrc warning ignore /home/deploy/apps/team_hadley/releases/20161105191648/Gemfile'.
DEBUG [d02096e8]
DEBUG [d02096e8] To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31mThe following gems are missingESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * nokogiri (1.6.8.1)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * globalid (0.3.7)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * net-ssh (3.2.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * net-scp (1.2.1)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * sshkit (1.11.3)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * airbrussh (1.1.1)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * debug_inspector (0.0.2)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * binding_of_caller (0.7.2)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * capistrano-harrow (0.5.3)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * capistrano (3.6.1)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * capistrano-bundler (1.2.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * capistrano-rails (1.1.8)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * capistrano-rvm (0.1.2)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * capistrano-sidekiq (0.5.4)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * capistrano3-puma (1.2.1)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * coderay (1.1.1)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * database_cleaner (1.5.3)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * responders (2.3.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * diff-lcs (1.2.5)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * docile (1.1.5)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * factory_girl (4.7.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * factory_girl_rails (4.7.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * jbuilder (2.6.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * jquery-rails (4.2.1)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * turbolinks (5.0.1)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * materialize-sass (0.97.7)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * method_source (0.8.2)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * slop (3.6.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * pry (0.10.4)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * sprockets (3.7.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * sprockets-rails (3.2.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * react-rails (1.9.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * rspec-support (3.5.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * rspec-core (3.5.4)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * rspec-expectations (3.5.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * rspec-mocks (3.5.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * rspec-rails (3.5.2)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * sass-rails (5.0.6)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * sdoc (0.4.2)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * shoulda-matchers (3.1.1)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * simplecov-html (0.10.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * simplecov (0.11.2)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * spring (2.0.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * sprockets-es6 (0.9.2)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * uglifier (3.0.2)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[31m * web-console (2.3.0)ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] ESC[33mInstall missing gems with `bundle install`ESC[0m
DEBUG [d02096e8]
DEBUG [d02096e8] Finished in 1.037 seconds with exit status 1 (failed).
INFO [62fad7fd] Running ~/.rvm/bin/rvm default do bundle install --path /home/deploy/apps/team_hadley/shared/bundle --without development test --deployment --quiet on 162.243.135.130
DEBUG [62fad7fd] Command: cd /home/deploy/apps/team_hadley/releases/20161105191648 && ~/.rvm/bin/rvm default do bundle install --path /home/deploy/apps/team_hadley/shared/bundle --without development test --deployment --quiet
DEBUG [62fad7fd] ESC[32mRVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
DEBUG [62fad7fd]
DEBUG [62fad7fd] you can ignore these warnings with 'rvm rvmrc warning ignore /home/deploy/apps/team_hadley/releases/20161105191648/Gemfile'.
DEBUG [62fad7fd]
DEBUG [62fad7fd] To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.
DEBUG [62fad7fd]
DEBUG [62fad7fd] ESC[0m
DEBUG [62fad7fd]
DEBUG [62fad7fd] bash: line 1: 7571 Killed ~/.rvm/bin/rvm default do bundle install --path /home/deploy/apps/team_hadley/shared/bundle --without development test --deployment --quiet
Here is my Capfile:
# Load DSL and Setup Up Stages
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
And my deploy.rb file:
server '162.243.135.130', port: 22, roles: [:web, :app, :db], primary: true
set :repo_url, '[email protected]:mghadley/team_hadley.git'
set :application, 'team_hadley'
set :user, 'deploy'
set :puma_threads, [4, 16]
set :puma_workers, 0
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to false when not using ActiveRecord
## Defaults:
# set :scm, :git
# set :branch, :master
# set :format, :pretty
# set :log_level, :debug
# set :keep_releases, 5
## Linked Files & Directories (Default None):
# set :linked_files, %w{config/database.yml}
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) 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
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:restart'
end
end
before :starting, :check_revision
after :finishing, :compile_assets
after :finishing, :cleanup
after :finishing, :restart
end
# ps aux | grep puma # Get puma pid
# kill -s SIGUSR2 pid # Restart puma
# kill -s SIGTERM pid # Stop puma
And, lastly, my Gemfile:
source 'https://rubygems.org'
ruby '2.2.3'
gem 'rails', '4.2.5'
gem 'pg', '~> 0.15'
gem 'sass-rails', '~> 5.0'
gem 'materialize-sass', '~> 0.97.6'
gem 'uglifier', '>= 1.3.0'
gem 'devise', '~> 4.1.1'
gem 'jquery-rails'
gem 'jquery-turbolinks'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem "sprockets"
gem "sprockets-es6"
gem "react-rails"
gem "cloudinary"
gem "jquery-slick-rails"
gem "sidekiq"
group :development, :test do
gem 'pry', '~> 0.10.3'
gem 'rspec-rails'
gem 'shoulda-matchers', '~> 3.1.1'
gem 'database_cleaner', '~> 1.5.3'
gem 'simplecov', '~> 0.11.2'
gem 'factory_girl_rails', '~> 4.7.0'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'capistrano-sidekiq', require: false
gem 'capistrano', require: false
gem 'capistrano-rvm', require: false
gem 'capistrano-rails', require: false
gem 'capistrano-bundler', require: false
gem 'capistrano3-puma', require: false
end
group :produection do
gem 'rails_12factor'
gem 'puma'
end
Does anyone happen to know what is going wrong?
You're seeing output from bundle check
that gems are missing. This is expected because capistrano-bundler first runs bundle check
before running bundle install
. You can disregard the check
output.
The real problem is the last line of your log, which says:
bash: line 1: 7571 Killed ~/.rvm/bin/rvm default do bundle install --path /home/deploy/apps/team_hadley/shared/bundle --without development test --deployment --quiet
As you can see, bundle install
is failing due to be killed by the operating system. This is almost certainly because you have exhausted the RAM and the OS is forced to stop the process.
As a solution, you can either add swap to your VM or upgrade to a VM with more RAM.
To be sure, check the logs in /var/log/syslog
and look for memory-related errors.