簡體   English   中英

不知道如何在使用 Rails 為 capistrano 3.8.0 運行“cap production deploy”時構建任務“start”

[英]Don't know how to build task 'start' when run 'cap production deploy' for capistrano 3.8.0 with Rails

我嘗試使用 capistrano 部署我的 rails 站點。 所以當我跑

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

所以上面的代碼之前是有效的,但是當我更新我的 gem 時,我就無法再部署我的應用程序了。

那么我該如何解決這個問題?

謝謝!

require 'capistrano/puma'之后將install_plugin Capistrano::Puma添加到您的Capfile 中

幾天前, capistrano3-puma升級到 3.0。 在此版本中加載默認 puma 任務需要此行。

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

這些任務需要在 Capfile 中包含一些插件。 Jin 的回答部分解決了這個問題,並在回答下的評論提到了這一點。

這是一個答案,它總結了有效的方法。

對於 Capistrano < 3.15.0:

`require 'capistrano/puma'
install_plugin Capistrano::Puma

對於 Capistrano >= 3.15.0 & Puma < 5.0

require 'capistrano/puma'
install_plugin Capistrano::Puma
install_plugin Capistrano::Puma::Daemon

對於 Capistrano >= 3.15.0 & Puma >= 5.0

require 'capistrano/puma'
install_plugin Capistrano::Puma
install_plugin Capistrano::Puma::Systemd

這兩行應該在 Capfile 中。 此更改也在最近的 puma 版本 gem 'capistrano3-puma' 中完成。

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

請注意它們寫在 capfile 中的層次結構。 這有助於在 cap 中加載 puma 任務。 您可以使用cap -T列出 capistrano 任務。 使用以上兩行更新 Capfile 后,還要查找與 puma 相關的任務。

有關更多詳細信息,請參閱https://github.com/seuros/capistrano-puma#usage

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM