Symfony2 Capifony部署 - 在同一台服务器上发生冲突

时间:2012-09-04 00:58:25

标签: deployment symfony apc capifony

我想在同一台服务器上部署Git存储库的不同分支。

我已更新了app / config / deploy.rb

set :stage_dir, "app/config/deploy"
require "capistrano/ext/multistage"
set :stages, %w(prod stag stag2 stag3)
set :application, "MyApp"

我在app / config / deploy /

中创建了新文件

在app / config / deploy / stag.rb中:

set :symfony_env_prod, "stag"
set :domain,           "stag.example.com"
set :deploy_to,        "/var/www/#{domain}"

# Other config
role :web,             domain
role :app,             domain
role :db,              domain, :primary => true

在app / config / deploy / stag2.rb

set :symfony_env_prod, "stag"
set :domain,           "stag2.example.com"
set :deploy_to,        "/var/www/#{domain}"

# Other config
role :web,             domain
role :app,             domain
role :db,              domain, :primary => true

我也发布了cap stag2 deploy:setup

当我使用cap stag deploy部署时,stag.example.com很好

然后,当我部署cap stag2 deploy时,stag2.example.com是文件,但stag.example.com从stag2获得一些更改。 stag.example.com的源文件是正确的。我认为存在缓存冲突。

Capifony能否在同一服务器中正确部署相同的应用程序?

编辑:听起来类似Capistrano Multistage deploying to wrong directory

我也试过了set :deploy_to, "/var/www/stag2/#{domain}"

2 个答案:

答案 0 :(得分:0)

您必须使用server参数代替:domain

stag.rb

server "stag.example.com", :app, :web, :primary => true

stag2.rb

server "stag2.example.com", :app, :web, :primary => true

不要使用:domain来处理这些事情。

See the docs

答案 1 :(得分:0)

我尝试了你的解决方案@Elnur,用替换服务器,部署工作正常,但问题仍然存在...... 经过更多的调查和测试后,我想出了一个似乎有用的解决方案。

我注意到在app / autoload.php中我们使用APC

$loader = new ApcUniversalClassLoader('xx.');

xx。是在APC中创建命名空间的 A前缀 http://symfony.com/doc/2.0/components/class_loader.html

我替换为

$loader = new ApcUniversalClassLoader('xx.stagX');

然后重启Apache rm -Rf app / cache / *

这似乎解决了这个问题。如果同一服务器上的2个不同网站可以使用相同的APC名称空间,我会感到惊讶。

这是我们之前获得的异常堆栈跟踪,看看我们如何去 来自/var/www/stag5.XXXX.com/
to /var/www/ stag6.XXXX.com /

#10 /var/www/stag6.XXXX.com/shared/vendor/cg-library/src/CG/Proxy/MethodInvocation.php(58): JMS\SecurityExtraBundle\Security\Authorization\Interception\MethodSecurityInterceptor->intercept(Object(CG\Proxy\MethodInvocation))
#11 /var/www/stag5.XXXX.com/releases/20121210053804/app/cache/stag/jms_aop/proxies/St-XxBundle-Manager-XxxManager.php(85): CG\Proxy\MethodInvocation->proceed()
#12 /var/www/stag6.XXXX.com/releases/20121210060841/src/Xx/XxxBundle/Controller/XxxController.php(85): EnhancedProxy_16c750f17d8113ffbee7fc3acdc4b1625ca7410b\__CG__\St\CoreBundle\Manager\TagsManager->findXxxxx(Object(Xx\XxBundle\Entity\Project))
#13 [internal function]: Xx\XxxxxBundle\Controller\XxxxController->getXxxAction(Object(Symfony\Component\HttpFoundation\Request))
#14 /var/www/stag5.XXXX.com/releases/20121210053804/app/cache/stag/classes.php(4591): call_user_func_array(Array, Array)
#15 /var/www/stag5.XXXX.com/releases/20121210053804/app/cache/stag/classes.php(4555): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#16 /var/www/stag5.XXXX.com/releases/20121210053804/app/cache/stag/classes.php(5537): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/stag5.XXXX.com/releases/20121210053804/app/bootstrap.php.cache(564): Symfony\Bundle\FrameworkBundle\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/stag5.XXXX.com/releases/20121210053804/web/app_stag.php(13): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#19 {main}