我的 capistrano 配置有问题。我试图按照几个教程没有成功。当我部署时,一切都很好,但最后部署完成而没有启动 puma。
➜ api git:(master) ✗ cap production deploy
roicoeur@51.15.209.247's password:
rvm 1.29.9 (latest) by Michal Papis,Piotr Kuczynski,Wayne E. Seguin [https://rvm.io]
ruby-3.0.0
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
00:00 git:wrapper
01 mkdir -p /tmp
✔ 01 roicoeur@51.15.209.247 0.061s
Uploading /tmp/git-ssh-a0da9a635c16c5f6b69d.sh 100.0%
02 chmod 700 /tmp/git-ssh-a0da9a635c16c5f6b69d.sh
✔ 02 roicoeur@51.15.209.247 0.073s
00:00 git:check
01 git ls-remote git@gitlab.com:RoiCoeur/roi_coeur_api.git HEAD
01 15fa8415b1bdebdf2fddc3b3562c9bc6d86be5a9 HEAD
✔ 01 roicoeur@51.15.209.247 2.533s
00:02 deploy:check:directories
01 mkdir -p /data/roi_coeur_api/shared /data/roi_coeur_api/releases
✔ 01 roicoeur@51.15.209.247 0.020s
00:02 deploy:check:linked_dirs
01 mkdir -p /data/roi_coeur_api/shared/public/assets
✔ 01 roicoeur@51.15.209.247 0.064s
00:02 deploy:check:make_linked_dirs
01 mkdir -p /data/roi_coeur_api/shared/config
✔ 01 roicoeur@51.15.209.247 0.064s
00:03 git:clone
The repository mirror is at /data/roi_coeur_api/repo
00:03 git:update
01 git remote set-url origin git@gitlab.com:RoiCoeur/roi_coeur_api.git
✔ 01 roicoeur@51.15.209.247 0.077s
02 git remote update --prune
02 Fetching origin
02 From gitlab.com:RoiCoeur/roi_coeur_api
02 471f1356..15fa8415 master -> master
✔ 02 roicoeur@51.15.209.247 3.575s
00:07 git:create_release
01 mkdir -p /data/roi_coeur_api/releases/20210427082855
✔ 01 roicoeur@51.15.209.247 0.071s
02 git archive master | /usr/bin/env tar -x -f - -C /data/roi_coeur_api/releases/20210427082855
✔ 02 roicoeur@51.15.209.247 0.954s
00:08 deploy:set_current_revision
01 echo "15fa8415b1bdebdf2fddc3b3562c9bc6d86be5a9" > REVISION
✔ 01 roicoeur@51.15.209.247 0.068s
00:08 deploy:symlink:linked_files
01 mkdir -p /data/roi_coeur_api/releases/20210427082855/config
✔ 01 roicoeur@51.15.209.247 0.066s
02 ln -s /data/roi_coeur_api/shared/config/database.yml /data/roi_coeur_api/releases/20210427082855/config/database.yml
✔ 02 roicoeur@51.15.209.247 0.066s
03 rm /data/roi_coeur_api/releases/20210427082855/config/secrets.yml
✔ 03 roicoeur@51.15.209.247 0.063s
04 ln -s /data/roi_coeur_api/shared/config/secrets.yml /data/roi_coeur_api/releases/20210427082855/config/secrets.yml
✔ 04 roicoeur@51.15.209.247 0.065s
00:09 deploy:symlink:linked_dirs
01 mkdir -p /data/roi_coeur_api/releases/20210427082855/public
✔ 01 roicoeur@51.15.209.247 0.065s
02 rm -rf /data/roi_coeur_api/releases/20210427082855/public/assets
✔ 02 roicoeur@51.15.209.247 0.079s
03 ln -s /data/roi_coeur_api/shared/public/assets /data/roi_coeur_api/releases/20210427082855/public/assets
✔ 03 roicoeur@51.15.209.247 0.049s
00:09 bundler:config
01 ~/.rvm/bin/rvm default do bundle config --local deployment true
01 Unknown ruby interpreter version (do not know how to handle): 3.0.0.
✔ 01 roicoeur@51.15.209.247 1.043s
02 ~/.rvm/bin/rvm default do bundle config --local path /data/roi_coeur_api/shared/bundle
02 Unknown ruby interpreter version (do not know how to handle): 3.0.0.
✔ 02 roicoeur@51.15.209.247 0.987s
03 ~/.rvm/bin/rvm default do bundle config --local without development:test
03 Unknown ruby interpreter version (do not know how to handle): 3.0.0.
✔ 03 roicoeur@51.15.209.247 1.009s
00:13 bundler:install
The Gemfile's dependencies are satisfied,skipping installation
00:13 deploy:assets:precompile
01 ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
01 Unknown ruby interpreter version (do not know how to handle): 3.0.0.
01 Yarn executable was not detected in the system.
01 Download Yarn at https://yarnpkg.com/en/docs/install
01 Yarn executable was not detected in the system.
01 Download Yarn at https://yarnpkg.com/en/docs/install
✔ 01 roicoeur@51.15.209.247 148.221s
02:42 deploy:assets:backup_manifest
01 mkdir -p /data/roi_coeur_api/releases/20210427082855/assets_manifest_backup
✔ 01 roicoeur@51.15.209.247 0.063s
02 cp /data/roi_coeur_api/releases/20210427082855/public/assets/.sprockets-manifest-8ff059873481df0a51f05274710bdeca.json /data/roi_coeur_api/releases/20210427082855/assets_manifest_backup
✔ 02 roicoeur@51.15.209.247 0.071s
02:42 deploy:symlink:release
01 ln -s /data/roi_coeur_api/releases/20210427082855 /data/roi_coeur_api/releases/current
✔ 01 roicoeur@51.15.209.247 0.060s
02 mv /data/roi_coeur_api/releases/current /data/roi_coeur_api
✔ 02 roicoeur@51.15.209.247 0.276s
02:42 deploy:cleanup
Keeping 5 of 6 deployed releases on 51.15.209.247
01 rm -rf /data/roi_coeur_api/releases/20210426123044
✔ 01 roicoeur@51.15.209.247 0.086s
02:43 deploy:log_revision
01 echo "Branch master (at 15fa8415b1bdebdf2fddc3b3562c9bc6d86be5a9) deployed as release 20210427082855 by remybeauperin" >> /data/roi_coeur_api/revisions.log
✔ 01 roicoeur@51.15.209.247 0.068s
➜ api git:(master)
你可以在这里看到我的 capistrano 配置:
# puma.rb
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
threads threads_count,threads_count
port ENV.fetch('PORT') { 3000 }
environment ENV.fetch('RAILS_ENV') { 'development' }
plugin :tmp_restart
####################################################
# deploy.rb
lock "~> 3.16.0"
set :application,'app'
set :repo_url,'git@gitlab.com:******/******.git'
set :deploy_to,-> { "/data/#{fetch(:application)}" }
# Default branch is :master
# ask :branch,`git rev-parse --abbrev-ref HEAD`.chomp
set :branch,ENV['BRANCH'].nil? ? :master : ENV['BRANCH']
# set :pty,true
set :ssh_options,forward_agent: true,keys: [
File.join(ENV['HOME'],'.ssh','id_rsa')
]
append :linked_files,'config/database.yml','config/secrets.yml'
after "deploy:updated","deploy:migrate"
####################################################
# Capfile
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require 'capistrano/rails'
require "capistrano/rvm"
require "capistrano/bundler"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"
require "capistrano/puma"
install_plugin Capistrano::Puma
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
####################################################
# Gemfile
ruby '3.0.0'
source 'https://rubygems.org'
...
gem 'puma'
group :development do
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
####################################################
我无法解释这个问题。谁能看到它是什么?
编辑
当我尝试在我的 deploy.rb 中强制 puma:restart 时,我有这个:
Caused by:
Don't know how to build task 'puma:restart' (See the list of available tasks with `cap --tasks`)
而且在 cap --tasks
中,我对 Puma cmd 一无所知:
...
cap git:wrapper # Upload the git wrapper script,this script guarantees that we can script git without getting an interactive prompt
cap install # Install Capistrano,cap install STAGES=staging,production
cap puma:config # Setup Puma config file
cap rvm:check # Prints the RVM and Ruby version on the target host