ruby-on-rails – 如何在ROR部署中为git capistrano 3配置远程引用?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 如何在ROR部署中为git capistrano 3配置远程引用?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用capistrano(第一次)部署我的rails应用程序.首先要点,我正在使用:

>ruby1.9.3p362
> Rails 3.2.13
> rvm 1.24.7
> Capistrano 3.0.1
> Phusion Passenger 4.0.26
> Ubuntu 12.04 LTS

尝试运行cap生产部署时出现以下错误

DEBUG [679a47be]致命:没有远程配置列出引用.

我的全面生产部署输出包括在下面

  1. INFO [488ba755] Running /usr/bin/env mkdir -p /tmp/AppName/ on sub.example.com
  2. DEBUG [488ba755] Command: /usr/bin/env mkdir -p /tmp/AppName/
  3. INFO [488ba755] Finished in 1.730 seconds with exit status 0 (successful).
  4. DEBUG Uploading /tmp/AppName/git-ssh.sh 0.0%
  5. INFO Uploading /tmp/AppName/git-ssh.sh 100.0%
  6. INFO [c895f068] Running /usr/bin/env chmod +x /tmp/AppName/git-ssh.sh on sub.example.com
  7. DEBUG [c895f068] Command: /usr/bin/env chmod +x /tmp/AppName/git-ssh.sh
  8. INFO [c895f068] Finished in 0.217 seconds with exit status 0 (successful).
  9. DEBUG [679a47be] Running /usr/bin/env git ls-remote on sub.example.com
  10. DEBUG [679a47be] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/AppName/git-ssh.sh /usr/bin/env git ls-remote )
  11. DEBUG [679a47be] fatal: No remote configured to list refs from.
  12. DEBUG [679a47be] Finished in 1.775 seconds with exit status 128 (Failed).

的Gemfile

  1. # Deploy with Capistrano
  2. gem 'capistrano','~> 3.0.0'
  3. gem 'capistrano-rails','~> 1.1.0'
  4. gem 'rvm1-capistrano3',require: false

Capfile

  1. # Load DSL and Setup Up Stages
  2. require 'capistrano/setup'
  3.  
  4. # Includes default deployment tasks
  5. require 'capistrano/deploy'
  6.  
  7. # require 'capistrano/rvm'
  8. # require 'capistrano/rbenv'
  9. # require 'capistrano/chruby'
  10. require 'capistrano/bundler'
  11. require 'capistrano/rails/assets'
  12. require 'capistrano/rails/migrations'
  13.  
  14. # Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
  15. Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

deploy.rb

我已经更改了这个文件添加我的git url,应用程序名称,deploy_to路径以及任务内的任务:按照指示重新启动Phusion Passenger.

  1. set :application,'AppName'
  2. set :deploy_to,'/var/www/appname'
  3.  
  4. set :repository,"git@github.com:username/appname.git" # Your clone URL
  5. set :scm,"git"
  6. set :user,"my-github-deploy-user" # The server's user for deploys
  7. set :scm_passphrase,"correct-password" # The deploy user's password
  8. set :branch,"master"
  9. set :deploy_via,:remote_cache
  10.  
  11. # ask :branch,proc { `git rev-parse --abbrev-ref HEAD`.chomp }
  12.  
  13. set :ssh_options,{
  14. verbose: :debug
  15. }
  16.  
  17. set :format,:pretty
  18. set :log_level,:debug
  19. # set :pty,true
  20.  
  21. set :linked_files,%w{config/database.yml}
  22. set :linked_dirs,%w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
  23.  
  24. # set :default_env,{ path: "/opt/ruby/bin:$PATH" }
  25. # set :keep_releases,5
  26.  
  27. namespace :deploy do
  28.  
  29. desc 'Restart application'
  30. task :restart do
  31. on roles(:app),in: :sequence,wait: 5 do
  32. # Your restart mechanism here,for example:
  33. execute :touch,release_path.join('tmp/restart.txt')
  34. # task :start do ; end
  35. # task :stop do ; end
  36. # task :restart,:roles => :app,:except => { :no_release => true } do
  37. # run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  38. # end
  39. end
  40. end
  41.  
  42. after :restart,:clear_cache do
  43. on roles(:web),in: :groups,limit: 3,wait: 10 do
  44. # Here we can do anything such as:
  45. within release_path do
  46. execute :rake,'cache:clear'
  47. end
  48. end
  49. end
  50. after :finishing,'deploy:cleanup'
  51. end

我试图包含所有必要的信息,请告诉我是否还有其他任何我可以添加内容,感谢您提供的任何帮助!

解决方法

在Capistrano 3中,您使用repo_url而不是存储库

所以在你的deploy.rb中,尝试替换

  1. set :repository,"git@github.com:username/appname.git" # Your clone URL

  1. set :repo_url,"https://github.com/username/appname.git" # Your clone URL

希望这会有所帮助.

更新:ssh URL需要一个密钥; https网址没有.它对我有用.

猜你在找的Ruby相关文章