1

I want to deploy different branchs of a Git repository on a same server.

I've updated app/config/deploy.rb

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

I've created new files in app/config/deploy/

In 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

In 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

I also launched cap stag2 deploy:setup.

When I deploy using cap stag deploy, stag.example.com is fine

Then, when I deploy cap stag2 deploy,stag2.example.com is file but stag.example.com get some changes from stag2. The source files of stag.example.com are correct. I suppose that there is a cache conflict.

Is Capifony able to deploy the same app in a same server properly ?

Edit : sounds similar Capistrano Multistage deploying to wrong directory

I also tried with set :deploy_to, "/var/www/stag2/#{domain}"

Community
  • 1
  • 1
Jerem
  • 460
  • 5
  • 13

2 Answers2

0

You have to use the server parameters instead of :domain.

stag.rb:

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

stag2.rb:

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

Don't use :domain for this stuff.

See the docs.

Elnur Abdurrakhimov
  • 44,533
  • 10
  • 148
  • 133
0

I tried your solution @Elnur , replacing server by domain, deployment works fine but the problem still occurs... After more investigation and tests I came up with a solution that seems to work.

I noticed that in app/autoload.php we use APC

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

xx. is the A prefix to create a namespace in APC http://symfony.com/doc/2.0/components/class_loader.html

I replaced by

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

Then restart Apache and rm -Rf app/cache/*

That seems to solve the problem. I would be surprised if the same APC name space could be used by 2 different websites on the same server.

This is the exception stack-trace that we got before, look how we go
from /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}
Jerem
  • 460
  • 5
  • 13