カピストラーノを使用して、Ruby On Rails アプリをステージングと本番の両方にデプロイしようとしています。
2 つの唯一の違いは、:domain と :repository です。
ここでこのガイドに従いました: https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension
私はネット上を検索しましたが、基本的に上記のものを焼き直している記事しか見つかりませんでした。
config/deploy/staging.rb と config/deploy/production.rb に :domain と :repository を設定してみました
スペルをチェックして、サブディレクトリとファイル名のスペルが正しいことを確認しました。
この記事を読んで:カピストラーノを使用したステージングとライブアプリ、ここで違いを宣言できるはずです。
staging.rb ファイルが実際に読み取られているようには見えません。「deploy.rb」を変更して、最初の行に 1 つの悪口を入れると、「cap deploy」で予想されるエラーが表示されます。
「staging.rb」または「production.rb」の最初の行に 1 つの悪口を入れると、同じエラーが発生します。
`method_missing': undefined local variable or method `domain'
問題の行は次のとおりです。
role :web, domain
値が取得されていないためです。しかし、確かに、staging.rb または production.rb の 1 つの誓いの言葉で失敗し、まったく実行されないはずですか?
:domain と :repository をメインの「deploy.rb」ファイルに戻すと、誓いの言葉でエラーが発生します。そのため、「staging.rg」ファイルと「production.rb」ファイルに変数を設定できず、タスクを完了するだけのようです。
何か助けていただければ幸いです。それとも、私がピザ配達の仕事を引き受けるべきだと思いますか...
deploy.rb:
require 'capistrano/ext/multistage'
set :stages, %w(production staging)
set :default_stage, "staging"
set :user, 'dave'
set :applicationdir, "~/rails/example.com"
set :scm, 'git'
set :git_enable_submodules, 1 # if you have vendored rails
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true
set :keep_releases, 5
after "deploy:update", "deploy:cleanup"
# roles (servers)
role :web, domain
role :app, domain
role :db, domain, :primary => true
after "deploy", "deploy:migrate"
# deploy config
set :deploy_to, applicationdir
set :deploy_via, :export
# set :rake, 'bundle exec rake'
# additional settings
default_run_options[:pty] = true # Forgo errors when deploying from windows
set :ssh_options, {:forward_agent => true}
#ssh_options[:keys] = %w(/home/user/.ssh/id_rsa) # If you are using ssh_keysset :chmod755, "app config db lib public vendor script script/* public/disp*"set :use_sudo, false
# Passenger
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run " touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
そして、私の config/deploy/staging.rb ファイル:
set :domain, 'example.com'
set :repository, "ssh://dave@example.com/~/rails/chamonix-mont-blanc.net"
:domain と :repository をメインの "deploy.rb" に配置すると、すべて正常に動作します。