Capistrano + Git:生产服务器的本地存储库

时间:2010-02-19 00:08:04

标签: ruby-on-rails git deployment capistrano

我正在为我的应用尝试“部署:冷”。 git repo是本地的 我的部署服务器(即我只有一台服务器和我 不要在github上托管我的代码。

以下是成绩单(将我的应用名称替换为“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

这是我的deploy.rb:http://pastie.org/831424

我也试过

set :repository, "deploy@localhost:/home/mrichman/git/myapp.git"

但是这给了我

ssh: connect to host localhost port 22: Connection refused

任何想法都表示赞赏。

5 个答案:

答案 0 :(得分:16)

刚遇到同样的问题。关键是不要使用deploy_via副本,而是设置:local_repository

这应该设置为用于从开发计算机/笔记本电脑访问存储库的URL。

所以我的

set :repository, "file:///srv/git/myapp.git"
set :local_repository, "nameOfHostFromSSHConfig:/srv/git/myapp.git"

似乎已经奏效了。请记住,然后删除deploy_via副本行。

答案 1 :(得分:1)

以您要部署的站点的用户身份登录,并尝试查看您的用户是否有权访问该目录:

ls -la /home/mrichman/git/myapp.git

如果您收到Permission denied错误,那么您必须确保在存储库的封闭目录上设置权限,允许部署脚本访问这些文件。

答案 2 :(得分:0)

确保您已经编写了正确的git repo,其中包含区分大小写的写作! (我遇到了同样的问题,它刚刚解决了)

答案 3 :(得分:0)

我的问题实际上与已知主机问题有关。我所要做的就是确保远程git服务器在我的已知主机中(第一次尝试SSH进入它会提示你自己添加它),它就像一个魅力。

答案 4 :(得分:0)

如果设置了local_repository,则Capistrano将使用部署服务器中的respository值和开发服务器中的local_respository值。 Or something like that.

我的配置如下:

set :repository, "/home/#{user}/path/to/repo.git"
set :local_repository, "myserver.com:path/to/repo.git"