Capistrano + Git:生产服务器本地的存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2293212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Capistrano + Git : repository local to production server
提问by Mark Richman
I am trying to do 'deploy:cold' for my app. The git repo is local to my deployment server (i.e. I only have one server for everything and I don't host my code on github).
我正在尝试为我的应用程序执行“部署:冷”。git repo 位于我的部署服务器的本地(即我只有一台服务器来处理所有事情,而且我没有在 github 上托管我的代码)。
Here is the transcript (replaced my app name with "myapp" for privacy)
这是成绩单(为了隐私,将我的应用程序名称替换为“myapp”)
* executing `deploy:cold'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "git ls-remote /home/mrichman/git/myapp.git master"
fatal: '/home/mrichman/git/myapp.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/myapp.com/releases/20100218203108; true"
servers: ["myapp.com"]
Password:
[myapp.com] executing command
command finished
Command git ls-remote /home/mrichman/git/myapp.git master returned status code 32768
Here is my deploy.rb: http://pastie.org/831424
这是我的 deploy.rb:http://pastie.org/831424
I have also tried
我也试过
set :repository, "deploy@localhost:/home/mrichman/git/myapp.git"
but that gives me
但这给了我
ssh: connect to host localhost port 22: Connection refused
Any ideas are appreciated.
任何想法表示赞赏。
采纳答案by pmarsh
Just ran into the same problem. The key is to not use deploy_via copy but rather set :local_repository
刚遇到同样的问题。关键是不要使用 deploy_via copy 而是设置 :local_repository
This should be set to the URL you use to access the repository from your development computer/laptop.
这应该设置为您用于从开发计算机/笔记本电脑访问存储库的 URL。
So mine has
所以我的有
set :repository, "file:///srv/git/myapp.git"
set :local_repository, "nameOfHostFromSSHConfig:/srv/git/myapp.git"
Seems to have worked. Just remember to then remove the deploy_via copy line as well.
似乎奏效了。只记得然后删除 deploy_via 复制行。
回答by rwl4
Log in as the user of the site you are deploying to and try this to see if your user has permission to access that directory:
以您要部署到的站点的用户身份登录并尝试执行此操作以查看您的用户是否有权访问该目录:
ls -la /home/mrichman/git/myapp.git
ls -la /home/mrichman/git/myapp.git
If you get a Permission denied error then you'll have to make sure that you set permissions on the enclosing directories of the repository that allow the deployment script to access the files.
如果您收到 Permission denied 错误,那么您必须确保在存储库的封闭目录上设置权限,以允许部署脚本访问文件。
回答by mustafaturan
Make sure that you have written the correct git repo with caring case-sensitivewriting! (I faced the same problem, it just solved)
确保您使用区分大小写的方式编写了正确的 git repo !(我遇到了同样的问题,它刚刚解决了)
回答by Ben Kreeger
My problem was actually related to a known-hosts problem. All I had to do was make sure the remote git server was in my known hosts (trying to SSH into it for the first time will prompt you to add this yourself), and it worked like a charm.
我的问题实际上与已知主机问题有关。我所要做的就是确保远程 git 服务器在我已知的主机中(第一次尝试通过 SSH 连接到它会提示你自己添加它),它就像一个魅力。
回答by Fletcher Moore
If local_repository
is set, then Capistrano uses the value of respository
from the deployment server and the value of local_respository
from the development server. Or something like that.
如果local_repository
设置,则 Capistrano 使用respository
来自部署服务器的值和local_respository
来自开发服务器的值。或类似的东西。
My configuration worked like so:
我的配置是这样工作的:
set :repository, "/home/#{user}/path/to/repo.git"
set :local_repository, "myserver.com:path/to/repo.git"