在尝试部署,其他问题都解决了,剩下这 4 块不知道是哪里出错了导致的。
执行的 cap production deploy --trace,以下是失败的几处地方 (完整的部署 trace 信息在最后)。希望能得到帮助...
我的 gemfile 如下:
source "http://gems.ruby-china.org"
gem 'rails', '~> 5.1.4'
gem 'sqlite3'
gem 'puma', '~> 3.7'
gem 'sprockets'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'mysql2'
# Redis
gem 'redis'
gem 'hiredis'
gem 'redis-namespace'
gem 'redis-objects'
group :development do
gem 'capistrano', '~> 3.4.0', require: false
gem 'capistrano-bundler', require: false
gem 'capistrano-rails', require: false
gem 'capistrano-rvm', require: false
gem 'capistrano3-puma', require: false
gem 'pry-nav'
# Better Errors
gem 'better_errors'
gem 'binding_of_caller'
gem 'spring'
gem 'spring-commands-rspec'
gem 'listen'
end
这是 capfile.rb
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'
server 'xxx.xxx.xxx', port: 22, roles: [:web, :app, :db], primary: true
set :repo_url, '[email protected]'
set :application, 'mydemo'
set :user, 'deploy'
set :puma_threads, [4, 16]
set :puma_workers, 0
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/home/#{fetch(:user)}/production/#{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, false # Change to true if using ActiveRecord
set :linked_files, fetch(:linked_files, []).push('config/database.yml')
set :shared_files, fetch(:shared_files, []).push('tmp')
namespace :puma do
desc 'Create Directories'
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
task :compile_assets do
on roles(:app) do
execute "cd #{current_path}"
execute "RAILS_ENV=production bundle exec rails assets:precompile"
end
end
namespace :deploy do
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
after :finishing, :compile_assets
after :finishing, :cleanup
after :finishing, :restart
end
这是报错的地方
** Invoke deploy:symlink:shared (first_time)
** Execute deploy:symlink:shared
** Invoke deploy:symlink:linked_files (first_time)
** Execute deploy:symlink:linked_files
DEBUG[66b3913f] Running [ -L /home/deploy/production/mydemo/releases/20180223075057/config/database.yml ] on xxx.xxx.xxx
DEBUG [66b3913f] Command: [ -L /home/deploy/production/mydemo/releases/20180223075057/config/database.yml ]
DEBUG [66b3913f] Finished in 0.154 seconds with exit status 1 (failed).
DEBUG [6813fe7a] Running [ -f /home/deploy/production/mydemo/releases/20180223075057/config/database.yml ] on xxx.xxx.xxx
DEBUG [6813fe7a] Command: [ -f /home/deploy/production/mydemo/releases/20180223075057/config/database.yml ]
DEBUG [6813fe7a] Finished in 0.155 seconds with exit status 1 (failed).
---
** Invoke deploy:symlink:linked_dirs (first_time)
** Execute deploy:symlink:linked_dirs
DEBUG [89e2dc88] Running [ -L /home/deploy/production/mydemo/releases/20180223075057/public/assets ] on xxx.xxx.xxx
DEBUG [89e2dc88] Command: [ -L /home/deploy/production/mydemo/releases/20180223075057/public/assets ]
DEBUG [89e2dc88] Finished in 0.155 seconds with exit status 1 (failed).
DEBUG [38254a1e] Running [ -d /home/deploy/production/mydemo/releases/20180223075057/public/assets ] on xxx.xxx.xxx
DEBUG [38254a1e] Command: [ -d /home/deploy/production/mydemo/releases/20180223075057/public/assets ]
DEBUG [38254a1e] Finished in 0.155 seconds with exit status 1 (failed).
---
** Invoke deploy:updated (first_time)
** Invoke bundler:install (first_time)
** Execute bundler:install
DEBUG [13b118d3] Command: cd /home/deploy/production/mydemo/releases/20180223075057 && ~/.rvm/bin/rvm default do bundle check --path /home/deploy/production/mydemo/shared/bundle
DEBUG [13b118d3] The following gems are missing
DEBUG [13b118d3]
DEBUG [13b118d3] * coderay (1.1.2)
...
(此处说有几个gems缺失)
...
DEBUG [13b118d3] Install missing gems with `bundle install`
DEBUG [13b118d3]
DEBUG [13b118d3] Finished in 0.873 seconds with exit status 1 (failed).
---
** Invoke deploy:compile_assets
** Invoke deploy:cleanup
** Invoke deploy:restart (first_time)
** Execute deploy:restart
** Invoke puma:restart (first_time)
** Execute puma:restart
DEBUG [7cb84c39] Running [ -f /home/deploy/production/mydemo/shared/tmp/pids/puma.pid ] on xxx.xxx.xxx
DEBUG [7cb84c39] Command: [ -f /home/deploy/production/mydemo/shared/tmp/pids/puma.pid ]
DEBUG [7cb84c39] Finished in 0.157 seconds with exit status 1 (failed).