Ami*_*tel 12 deployment ruby-on-rails github digital-ocean capistrano3
我在使用Capistrano 3部署Rails 4应用程序时遇到以下错误
INFO [87512eb8] Running /usr/bin/env chmod +x /tmp/magnificent/git-ssh.sh as deploy@104.236.6.180
DEBUG [87512eb8] Command: /usr/bin/env chmod +x /tmp/magnificent/git-ssh.sh
INFO [87512eb8] Finished in 0.444 seconds with exit status 0 (successful).
INFO [1ec94dd1] Running /usr/bin/env git ls-remote --heads git@github.com:BoTreeConsultingTeam/magnificent.git as deploy@104.236.6.180
DEBUG [1ec94dd1] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/magnificent/git-ssh.sh /usr/bin/env git ls-remote --heads git@github.com:BoTreeConsultingTeam/magnificent.git )
DEBUG [1ec94dd1] ERROR: Repository not found.
DEBUG [1ec94dd1] fatal: Could not read from remote repository.
DEBUG [1ec94dd1]
DEBUG [1ec94dd1] Please make sure you have the correct access rights
DEBUG [1ec94dd1] and the repository exists.
Run Code Online (Sandbox Code Playgroud)
这是capistrano配置.
配置/ deploy.rb
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'magnificent'
set :repo_url, 'git@github.com:BoTreeConsultingTeam/magnificent.git'
set :deploy_to, '/home/deploy/magnificent'
set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :branch, 'develop' #set/ :branch,`git rev-parse --abbrev-ref HEAD`.chomp
set :ssh_options, { forward_agent: true }
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
end
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
Run Code Online (Sandbox Code Playgroud)
production.rb
set :stage, :production
server 'xx.xx.xx.xx', user: 'deploy', roles: %w{web app}
Run Code Online (Sandbox Code Playgroud)
Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
set :rvm_type, :user
set :rvm_ruby_version, '2.2.2'
Run Code Online (Sandbox Code Playgroud)
我还将远程服务器的/home/deploy/.ssh/id_rsa.pub复制到github部署密钥.
更新
我确认我能够访问远程repo并且GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/magnificent/git-ssh.sh /usr/bin/env git ls-remote --heads git@github.com:BoTreeConsultingTeam/magnificent.git
命令也 可以在远程服务器上运行.
Ami*_*tel 44
最近我使用不同的解决方案.在cap production deploy
我运行以下命令之前.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
我可以通过替换来解决这个问题
set :repo_url, 'git@github.com:BoTreeConsultingTeam/magnificent.git'
Run Code Online (Sandbox Code Playgroud)
同
set :repo_url, 'https://my_github_username:my_github_password@github.com/BoTreeConsultingTeam/magnificent'
Run Code Online (Sandbox Code Playgroud)
请注意,如果您的密码包含特殊字符,那么它应该是url编码的.您可以使用URI::encode
irb 快速编码.
通过使用Capistrano 2的其他部署,我永远不需要提供github凭据.
任何人都可以告诉我为什么要指定git用户名/密码repo_url
?
在upcase论坛帖子中还有一个解决方案也有效.
归档时间: |
|
查看次数: |
7005 次 |
最近记录: |