Bagaimana saya bisa menghindari kesalahan yang ditolak izin ketika mencoba untuk menyebarkan aplikasi rel dengan capistrano?

0

Total noob di sini. Saya mencoba untuk menyebarkan aplikasi melalui Capistrano. Saya mendapatkan izin ditolak kesalahan tanpa henti ketika saya mencoba menjalankan cap deploy: update. Tampaknya setidaknya beberapa kesalahan ini disebabkan oleh direktori yang hilang yang memicu kesalahan "Izin Ditolak". (Saya sedang melakukan setup pada root untuk sementara waktu.)

set :user, 'root'
set :domain, 'domainname.com'
set :application, 'appname'
# adjust if you are using RVM, remove if you are not
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, '1.9.2'
# file paths
set :repository, "ssh://[email protected]/~/git/appname.git"
set :deploy_to, "/var/rails/appname"
# distribute your applications across servers (the instructions below put them
# all on the same server, defined above as 'domain', adjust as necessary)
role :app, domain 
role :web, domain
role :db, domain, :primary => true
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'master'
set :scm_verbose, true
set :use_sudo, false
set :rails_env, :production
namespace :deploy do
desc "cause Passenger to initiate a restart"
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
desc "reload the database with seed data"
task :seed do
run "cd #{current_path}; rake db:seed RAILS_ENV=#{rails_env}"
end
end
after "deploy:update_code", :bundle_install
desc "install the necessary prerequisites"
task :bundle_install, :roles => :app do
run "cd #{release_path} && bundle install"
end

Inilah hasil saya:

** [domainname.com :: out] Cloning into '/var/rails/appname/shared/cached-copy'...
** [domainname.com :: err] Permission denied, please try again.
** [domainname.com :: err] Permission denied, please try again.
** [domainname.com :: err] Permission denied (publickey,gssapi-with-mic,password).
** [domainname.com :: err] fatal: The remote end hung up unexpectedly

Saya dapat ssh tanpa kata sandi, jadi tidak yakin tentang kesalahan publickey itu.

Omong-omong, jika saya lari cap deploy:updatetanpanya set :deploy_via, :remote_cache, inilah hasil saya:

 ** [domainname.com :: out] Cloning into '/var/rails/appname/releases/20120326204237'...
 ** [domainname.com :: err] Permission denied, please try again.
 ** [domainname.com :: err] Permission denied, please try again.
 ** [domainname.com :: err] Permission denied (publickey,gssapi-with-mic,password).
 ** [domainname.com :: err] fatal: The remote end hung up unexpectedly
command finished

Terima kasih banyak atas bantuan Anda dengan ini.

UPDATE Menambahkan ssh_options[:forward_agent] = trueke deploy.rb tampaknya agak memperbaiki keadaan.

Astaga
sumber
1
Tolong jangan posting jawaban di pertanyaan atau tambahkan "Dipecahkan" ke judul. Posting solusi sebagai jawaban. Jika Anda belum bisa menjawab, kirim komentar.
ChrisF

Jawaban:

0

Anda dapat menambahkan

set :admin_runner, "my_apps_username"

di config / deploy.rb. Sebagai alternatif, Anda dapat mengganti penyebaran: pengaturan tugas seperti ini:

namespace :deploy do
  task :setup, :except => { :no_release => true } do
    dirs = [deploy_to, releases_path, shared_path]
    dirs += shared_children.map { |d| File.join(shared_path, d.split('/').last) }
    run "mkdir -p #{dirs.join(' ')}"
    run "chmod g+w #{dirs.join(' ')}" if fetch(:group_writable, true)
  end
end
Jeroen Rosenberg
sumber