使用Capifony部署Symfony2应用-APC加载程序仍使用以前的版本 [英] Deploying Symfony2 app with Capifony - APC loader still uses previous release

查看:87
本文介绍了使用Capifony部署Symfony2应用-APC加载程序仍使用以前的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的Symfony2应用程序升级到2.1,并将其迁移到新服务器,因此我想配置 Capifony 使部署更简单。除了现在不使用APCLoader以外,其他一切都变得非常好,所以我不得不暂时将其注释掉,直到将其排序为止。

I've recently upgraded my Symfony2 application to 2.1 and migrated it to a new server, so I figured I'd configure Capifony to make deploying simpler. Everything has gone great except for the fact that it now doesn't make use of the APCLoader, so I've had to comment this out temporarily until it's sorted.

这里是来自 app.php 的相关代码:

Here's the relevant code from app.php:

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';

// Use APC for autoloading to improve performance.
// Change 'sf2' to a unique prefix in order to prevent cache key conflicts
// with other applications also using APC.

$loader = new ApcClassLoader('my_prefix', $loader);
$loader->register(true);

问题是'my_prefix'不是每个版本都不唯一,因此最终将尝试查找属于以前版本的缓存文件,这些文件可能存在或可能不存在。显然,这是一个很大的问题!

The problem is that 'my_prefix' isn't unique per release so it'll end up trying to look for cached files that belong to previous releases, which may or may not still be there. This is obviously a very big problem!

什么是最好的解决方案?我是否应该以某种方式编写一个任务,在部署之前将capifony运行,并将前缀更改为唯一的变量,例如#{latest_release} ?还是应该在每次部署后以某种方式重置APC缓存的全部内容?

What would be the best solution for this? Should I somehow write a task that capifony will run before deploying that changes the prefix to something unique, such as the #{latest_release} variable? Or should I somehow reset the entire contents of the APC cache after each deploy?

我不太确定执行这两种操作的最佳方法,所以如果您会推荐其中之一,能否请您指出正确的方向以实现它?还是有我没有想到的替代解决方案?

I'm not too sure of the best way to do either of these things, so if you'd recommend one of them could you please point me in the right direction to be able to implement it? Or is there an alternative solution that I haven't thought of?

推荐答案

您可以使用 ApcBundle ,它提供了一个命令,可在 web / 目录中创建新文件,通过HTTP执行它,然后将其删除。然后,您可以在部署脚本中使用 run / path / to / app / console apc:clear 命令。

You could use the ApcBundle, which provides a command that will create new file in the web/ directory, execute it through HTTP, then remove it. Then, you could use your run "/path/to/app/console apc:clear" command in your deployment script.

这篇关于使用Capifony部署Symfony2应用-APC加载程序仍使用以前的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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