Не знаю, как создать задачу "start" при запуске "cap production deploy" для capistrano 3.8.0 с Rails

Я попытался развернуть сайт rails с помощью capistrano. Поэтому, когда я запускал

cap production deploy

Вот что я получил

(Backtrace restricted to imported tasks)
cap aborted!
Don't know how to build task 'start' (see --tasks)

Tasks: TOP => production

Это мой файл cap

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

require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'
require 'capistrano/scm/git'

install_plugin Capistrano::SCM::Git

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

Это мой deploy.rb

set :repo_url,        'xxx'
set :application,     'xxx'
set :user,            'yyy'
set :puma_threads,    [4, 16]
set :puma_workers,    0

set :pty,             true
set :use_sudo,        false
set :stages,          ["staging", "production"]
set :default_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) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true  # Change to false when not using ActiveRecord

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
end

Итак, вышеприведенный код работает до этого, но когда я обновляю свои драгоценные камни, я больше не могу развертывать свое приложение.

Итак, как я могу это исправить?

Спасибо!

Ответы

Ответ 1

Добавьте install_plugin Capistrano::Puma в свой Capfile после require 'capistrano/puma'.

capistrano3-puma перенесен на 3.0 несколько дней назад. Эта строка требуется для загрузки заданий по умолчанию puma в этой версии.

См. https://github.com/seuros/capistrano-puma#usage

Ответ 2

Эти две строки должны быть в Capfile. Также эти изменения внесены в недавнюю версию пумы gem 'capistrano3-puma'.

require 'capistrano/puma'
install_plugin Capistrano::Puma  # Default puma tasks

Пожалуйста, обратите внимание на иерархию, в которой они написаны в capfile. Это помогает загружать задачи пумы в шапку. Вы можете перечислить задачи cap -T с помощью cap -T. Также поищите задание, связанное с puma, как только вы обновите Capfile с помощью двух строк выше.

Для получения дополнительной информации см. Https://github.com/seuros/capistrano-puma#usage.