1

我想在同一台服务器上部署 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 deploystag.example.com 部署时,它很好

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

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

编辑:听起来很像Capistrano Multistage 部署到错误的目录

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

4

2 回答 2

0

您必须使用server参数而不是:domain.

stag.rb

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

stag2.rb

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

不要:domain用于这种东西。

请参阅文档

于 2012-09-04T10:23:34.173 回答
0

我尝试了您的解决方案 @Elnur ,将server替换为domain,部署工作正常,但问题仍然存在......经过更多调查和测试,我想出了一个似乎可行的解决方案。

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

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

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

我替换为

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

然后重启 Apacherm -Rf app/cache/*

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

这是我们之前得到的异常堆栈跟踪,看看我们如何
从 /var/www/ stag5 .XXXX.com/
到 /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}
于 2012-12-10T07:31:27.450 回答