Capistrano Symlinks是否被缓存? [英] Capistrano Symlinks Being Cached?

查看:73
本文介绍了Capistrano Symlinks是否被缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在CentOS 6上使用Capistrano设置PHP部署,并且遇到了一个有趣的问题. capistrano的工作方式是这样设置文件夹:

I've been setting up PHP deployments with Capistrano on CentOS 6 and have run into an interesting issue. The way capistrano works, it sets up folders like this:

  • /var/www/myapp.com/
    • 当前(指向/releases中最新版本的符号链接)
    • 共享
    • 版本
      • 20130826172737
      • 20130826172114
      • /var/www/myapp.com/
        • current (symlink to latest release in /releases)
        • shared
        • releases
          • 20130826172737
          • 20130826172114

          当我查看当前"符号链接时,它指向最新版本.首先,当打开我的Web应用程序时,一切正常.部署新版本后,当前文件夹正确指向新版本,但是Web应用程序尝试从旧版本(在Capistrano清理过程中已删除)中加载文件.此外,虚拟主机配置为指向/var/www/myapp.com/current/Public .

          When I look at the "current" symlink, it points to the most recent release. At first, when opening my web app, everything worked fine. After deploying a new release, the current folder correctly points to the new release, but the web application tries to load files from the old release (which has been deleted in a Capistrano cleanup process). Also, the virtual host is configured to point at /var/www/myapp.com/current/Public.

          符号链接是否以任何方式缓存?

          Are symlinks cached in any way?

          失败的特定PHP代码(初始化我的框架)是这样的:

          The specific PHP code that fails (which initializes my framework) is this:

          require_once dirname(dirname(__FILE__)) . '/App/App.php';
          App\App::run();
          

          该文件位于当前位于/var/www/app.com/current/Public/index.php index.php 中.

          That is in index.php currently located at /var/www/app.com/current/Public/index.php.

          我的Apache错误日志显示:

          My Apache error logs show:

          PHP致命错误:require_once():无法打开所需的'/var/www/myapp.com/releases/20130826172237/App/App.php'(include_path ='.:/usr/share/pear:/usr/share/php'),位于/var/www/myapp.com/releases/20130826172237/Public/index.php

          PHP Fatal error: require_once(): Failed opening required '/var/www/myapp.com/releases/20130826172237/App/App.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/myapp.com/releases/20130826172237/Public/index.php

          当前符号链接显示:

          当前->/var/www/zverse/releases/20130826172641

          current -> /var/www/zverse/releases/20130826172641

          显然是20130826172641!= 20130826172237,后者是先前的版本.

          Obviously 20130826172641 != 20130826172237 which the latter was the previous version.

          我能看到的任何想法或领域吗?

          Any ideas or areas I can look at?

          推荐答案

          我无法验证这一点,但是在/缓存符号链接的旧位置之后,Apache似乎有一些不可预测的行为:

          I can't verify this, but it seems that there is some unpredictable behaviour with Apache following / caching the old location of symlinks:

          • Is there a way to mimic symlink behavior with an apache configuration?
          • Case Against Using Symlinks For Code Promotion

          唯一可以绝对解决此问题的方法是循环使用Apache,我们不希望在每个部署中都不要这样做. -Mike Brittain

          The only thing that would absolutely clear up this issue was to cycle Apache, which we would prefer not to do on every deployment. -- Mike Brittain

          他建议移动整个目录,而不是更新符号链接.

          He suggests moving the whole directory, instead of updating the symlink.

          这篇关于Capistrano Symlinks是否被缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆