【问题标题】:Capistrano's 'cap staging deploy' tasks complete successfully but changes don't appear on staging serverCapistrano 的“cap staging deploy”任务成功完成,但更改未出现在 staging 服务器上
【发布时间】:2015-12-10 07:42:30
【问题描述】:

这令人费解,因为我在运行“cap staging deploy”之前已正确更新并推送到 GIT 的 master 分支,但更改并未呈现在 staging 服务器上。

如果我能提供更多可能有用的信息,请告诉我。

提前感谢您的帮助。

应用也成功重启部署:

INFO [907b2583] Running /usr/bin/env touch /var/www/my_app/my_app-stgng/current/tmp/restart.txt as deploy@x.x.x.x
DEBUG [907b2583] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.1 /usr/bin/env touch /var/www/my_app/my_app-stgng/current/tmp/restart.txt )
INFO [907b2583] Finished in 0.666 seconds with exit status 0 (successful).

编辑:部署脚本设置为正确的分支,但是 /views 中的源代码与本地源不匹配。

编辑:正确的来源在 git repo master 分支中。这似乎表明我的部署来自与预期不同的分支。

编辑:与 GIT 相关的 Capistrano 部署日志摘录:

DEBUG Uploading /home/deploy/deploy_tmp/myappme_app/git-ssh.sh 0.0%
INFO Uploading /home/deploy/deploy_tmp/myappme_app/git-ssh.sh 100.0%
INFO [ffabbafb] Running /usr/bin/env chmod +x /home/deploy/deploy_tmp/myappme_app/git-ssh.sh as deploy@x.x.x.x
DEBUG [ffabbafb] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.1 /usr/bin/env chmod +x /home/deploy/deploy_tmp/myappme_app/git-ssh.sh )
INFO [ffabbafb] Finished in 0.640 seconds with exit status 0 (successful).
INFO [16e6d3cd] Running /usr/bin/env git ls-remote --heads git@bitbucket.org:CryptoWhippet/myappme_app.git as deploy@x.x.x.x
DEBUG [16e6d3cd] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.1 GIT_ASKPASS=/bin/echo GIT_SSH=/home/deploy/deploy_tmp/myappme_app/git-ssh.sh /usr/bin/env git ls-remote --heads git@bitbucket.org:CryptoWhippet/myappme_app.git )
DEBUG [16e6d3cd]        2cd85c80e2d9b4c33b791c341dd19894        refs/heads/master
INFO [16e6d3cd] Finished in 5.960 seconds with exit status 0 (successful).

[..]

DEBUG [4341e870] Running /usr/bin/env [ -f /var/www/my_app/my_app-stgng/repo/HEAD ] as deploy@x.x.x.x
DEBUG [4341e870] Command: [ -f /var/www/my_app/my_app-stgng/repo/HEAD ]
DEBUG [4341e870] Finished in 0.691 seconds with exit status 0 (successful).
INFO The repository mirror is at /var/www/my_app/my_app-stgng/repo
DEBUG [20a36e89] Running /usr/bin/env if test ! -d /var/www/my_app/my_app-stgng/repo; then echo "Directory does not exist '/var/www/my_app/my_app-stgng/repo'" 1>&2; false; fi as deploy@x.x.x.x
DEBUG [20a36e89] Command: if test ! -d /var/www/my_app/my_app-stgng/repo; then echo "Directory does not exist '/var/www/my_app/my_app-stgng/repo'" 1>&2; false; fi
DEBUG [20a36e89] Finished in 0.648 seconds with exit status 0 (successful).
INFO [6bb0fabc] Running /usr/bin/env git remote update as deploy@x.x.x.x
DEBUG [6bb0fabc] Command: cd /var/www/my_app/my_app-stgng/repo && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.1 GIT_ASKPASS=/bin/echo GIT_SSH=/home/deploy/deploy_tmp/myappme_app/git-ssh.sh /usr/bin/env git remote update )
DEBUG [6bb0fabc]        Fetching origin
INFO [6bb0fabc] Finished in 4.061 seconds with exit status 0 (successful).
DEBUG [bcc4ff25] Running /usr/bin/env if test ! -d /var/www/my_app/my_app-stgng/repo; then echo "Directory does not exist '/var/www/my_app/my_app-stgng/repo'" 1>&2; false; fi as deploy@x.x.x.x
DEBUG [bcc4ff25] Command: if test ! -d /var/www/my_app/my_app-stgng/repo; then echo "Directory does not exist '/var/www/my_app/my_app-stgng/repo'" 1>&2; false; fi
DEBUG [bcc4ff25] Finished in 0.648 seconds with exit status 0 (successful).
INFO [a3663844] Running /usr/bin/env mkdir -p /var/www/my_app/my_app-stgng/releases/20151209132220 as deploy@x.x.x.x
DEBUG [a3663844] Command: cd /var/www/my_app/my_app-stgng/repo && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.1 GIT_ASKPASS=/bin/echo GIT_SSH=/home/deploy/deploy_tmp/myappme_app/git-ssh.sh /usr/bin/env mkdir -p /var/www/my_app/my_app-stgng/releases/20151209132220 )                                                                                                                                                                                                                                                                     
INFO [a3663844] Finished in 0.650 seconds with exit status 0 (successful).
INFO [b2cf939e] Running /usr/bin/env git archive master | tar -x -f - -C /var/www/my_app/my_app-stgng/releases/20151209132220 as deploy@x.x.x.x
DEBUG [b2cf939e] Command: cd /var/www/my_app/my_app-stgng/repo && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.1 GIT_ASKPASS=/bin/echo GIT_SSH=/home/deploy/deploy_tmp/myappme_app/git-ssh.sh /usr/bin/env git archive master | tar -x -f - -C /var/www/my_app/my_app-stgng/releases/20151209132220 )                                                                                                                                                                                                                                          
INFO [b2cf939e] Finished in 3.266 seconds with exit status 0 (successful).
DEBUG [b21a4932] Running /usr/bin/env if test ! -d /var/www/my_app/my_app-stgng/repo; then echo "Directory does not exist '/var/www/my_app/my_app-stgng/repo'" 1>&2; false; fi as deploy@x.x.x.x
DEBUG [b21a4932] Command: if test ! -d /var/www/my_app/my_app-stgng/repo; then echo "Directory does not exist '/var/www/my_app/my_app-stgng/repo'" 1>&2; false; fi
DEBUG [b21a4932] Finished in 0.646 seconds with exit status 0 (successful).
DEBUG [efdb30ab] Running /usr/bin/env git rev-list --max-count=1 --abbrev-commit master as deploy@x.x.x.x
DEBUG [efdb30ab] Command: cd /var/www/my_app/my_app-stgng/repo && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.1 GIT_ASKPASS=/bin/echo GIT_SSH=/home/deploy/deploy_tmp/myappme_app/git-ssh.sh /usr/bin/env git rev-list --max-count=1 --abbrev-commit master )
DEBUG [efdb30ab]        8b9d346
DEBUG [efdb30ab] Finished in 0.630 seconds with exit status 0 (successful).

【问题讨论】:

  • 你能显示上限吗?重新启动服务器必须缺少它。
  • @Nithin,我也想过同样的事情,但它正在重新启动。我什至手动重新启动。将添加上面的信息。
  • 部署脚本中设置了预期的分支?手动检查一次服务器上的源代码。
  • @Nithin,有趣!在部署脚本中设置了正确的分支(默认保留),但手动检查服务器上的源显示 /views 中的代码与我的本地代码不匹配。
  • @Nithin,现在还要注意:正确的来源在 git repo master 分支中。这似乎表明我的部署来自与预期不同的分支。

标签: ruby-on-rails git deployment repository capistrano


【解决方案1】:

某些版本的 sass-rails 在部署时没有重新编译样式表存在错误。您应该首先检查临时服务器上的 git 目录是否与 master 中的相同,然后检查您添加的功能是否正常工作。如果是这样,那么您只有样式表或 javascript 的问题,您可能需要使用 gem 版本。

要找到有效的 gem 版本,您可以手动更改登台服务器上的 gemfile,然后使用与 capistrano 相同的命令用于捆绑和预编译资产。

如果没有帮助,请检查(由 capistrano 克隆的)存储库镜像以确认它与 origin/maser 处于相同状态。如果不匹配,并且您确定部署配置中的 git 存储库设置正确,则应清除存储库目录并重新运行部署例程。

【讨论】:

  • 尝试一个一个地重复 capistrano 命令,它可能会提示你出了什么问题。您是否检查过它是否真的在发布文件夹中发布?它可能不会更新“当前”符号链接。如果您使用 ssh 检查它,您可能会看到旧文件夹。 cd .. && cd current 以确保您查看“当前”符号链接正在查看的同一文件夹。
  • 没有看到日志,我猜一一执行命令应该会告诉你出了什么问题。您是否审查过它是否真的为 git 提取了正确的源代码?我不记得 capistrano 存储 git 副本的确切位置,但您可能清楚地看到它为此执行了什么命令,尝试执行该命令并检查 git 源是否与 master 上的相同。如果不是,那么 capistrano 会提取错误的 git 源。如果是,那么 capistrano 复制失败。我个人从未遇到过这样的问题,但应该很容易找出它失败的地方。
  • The repository mirror is at /var/www/my_app/my_app-stgng/repo 你可能应该检查它是否与 origin/master 处于相同的状态。
  • 您应该删除该目录并确保 capistrano 获取主分支。如果没有,我会检查部署配置并检查为什么没有。
  • 我编辑了您的答案以反映您帮助我推断的解决方案。一旦同行评审,我会接受它。谢谢@Fedcomp。
【解决方案2】:

您是否重新启动了服务器?

部署后我们需要做几件事你。

您可能需要在暂存配置文件中添加一些任务,以便在您想自动重新启动服务器时自动重新启动服务器。

after 'deploy:publishing', 'deploy:restart'

【讨论】:

  • 是的,它会重新启动。我已经更新了帖子以反映这一点。
猜你喜欢
  • 2014-06-29
  • 2013-03-10
  • 1970-01-01
  • 2013-03-15
  • 1970-01-01
  • 1970-01-01
  • 2012-09-03
  • 2021-03-28
  • 1970-01-01
相关资源
最近更新 更多