0

I've got a product I've deployed to a live Ubuntu 14.04 server, which works fine in app_dev. However, when I run it in app, it brings up a 503 error, with the below in the app log file:

I've got the exact same code in a Vagrant setup, same OS version and it works fine in both app and app_dev

Has anyone come across this before?

Symfony 2.7.0 / Ubuntu 14.04 / Distro PHP / mySQL - Tried clearing the cache & reinstalling all composer packages.

[2015-06-09 16:36:43] request.INFO: Matched route "fos_user_security_login". {"route_parameters":{"_controller":"FOS\UserBundle\Controller\SecurityController::loginAction","_route":"fos_user_security_login"},"request_uri":"http://xxxx/app.php/login"} []

[2015-06-09 16:36:43] security.INFO: Populated the TokenStorage with an anonymous Token. [] []

[2015-06-09 16:36:43] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpKernel\EventListener\SurrogateListener::__construct() must be an instance of Symfony\Component\HttpKernel\HttpCache\SurrogateInterface, instance of Symfony\Component\HttpKernel\HttpCache\Esi given, called in /var/www/xxxx/app/cache/prod/appProdProjectContainer.php on line 557 and defined" at /var/www/xxxx/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php line 33 {"exception":"[object] (Symfony\Component\Debug\Exception\ContextErrorException(code: 0): Catchable Fatal Error: Argument 1 passed to Symfony\Component\HttpKernel\EventListener\SurrogateListener::__construct() must be an instance of Symfony\Component\HttpKernel\HttpCache\SurrogateInterface, instance of Symfony\Component\HttpKernel\HttpCache\Esi given, called in /var/www/xxxx/app/cache/prod/appProdProjectContainer.php on line 557 and defined at /var/www/xxxx/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php:33)"} []

(To those who suggest code formatting the log lines, it formats them onto a single line, which basically means having to scroll them to read them, which is worse than above).

Unheilig
  • 16,196
  • 193
  • 68
  • 98
Steve Childs
  • 1,832
  • 2
  • 20
  • 26

1 Answers1

0

sigh - Always the case. You spend half an hour trying to solve it, you then post the question on SO and within 2 minutes you solve it yourself!

Thinking about the difference in setup between the vagrant setup is that the live box has more than 1 project active and then BINGO! it occurred to me.

The app environment uses APC to cache the classes and yes, both projects had the same apc cache key!

A quick key change and cache rebuild and its all fixed!

I thought I'd answer this incase anyone else had a similar issue.

Update:

A tweak to app.php....

// As APC requires a unique key prefix, we'll use the directory above     web, which will be unique.
$curdir = pathinfo(getcwd());
$curdir = basename($curdir['dirname']);
$loader = new ApcClassLoader($curdir . '_', $loader);
$loader->register(true);

This uses the folder above the cwd (usually apache's doc root) to prefix the key, as long as they're unique (it should be), then multiple cache's won't clash.

Steve Childs
  • 1,832
  • 2
  • 20
  • 26
  • Could you add a little more detail about how to change the cached key? Thx – Henry Jun 28 '15 at 21:03
  • @Henry - Updated the answer for you, hopefully this helps. – Steve Childs Jun 30 '15 at 14:54
  • Thanks. In the end I didn't change any cache keys. I was upgrading an older Symfony 2 project and in the end I replaced app.php with an updated out of the box prod version (2.6.9 in my case) and that fixed it. It seems I'd either tweaked the old app.php in the past and forgotten what I'd done, or it was simply incompatible with the new symfony 2 version I had installed. – Henry Jun 30 '15 at 23:06