capistrano / symfony

Capistrano tasks for deploying the Symfony standard edition
MIT License
354 stars 65 forks source link

Website unreachable during deploy #113

Closed ChoppyThing closed 5 years ago

ChoppyThing commented 5 years ago

Symfony 4/Php 7.2/ubuntu 18.04

Hi I wondering what i'm doing wrong in my deploy. I thought capistrano managed to switch current folders when the new version is fully built. But i'm getting the some errors and the app is unreachable for some minutes. request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Unable to write in the cache directory (/production/releases/20181127203847/var/cache/prod/twig/75)."

php.CRITICAL: Fatal Error: Method Gregwar\ImageBundle\ImageHandler::__toString() must not throw an exception, caught RuntimeException: Asset manifest file "/production/releases/20181127203847/public/dist/manifest.json" does not exist.

And more of these. My deploy conf look like this:

`# Locked capistrano version. lock "3.11.0"

set :application, "preprod"

set :deploy_to, "/site/#{fetch(:stage)}" set :tmp_dir, "/tmp/capistrano"

set :repo_url, "git@gitlab.com:repo.git"

set :linked_files, ['.env'] set :linked_dirs, ['var/log', 'public/upload', 'public/cache', 'public/pdf/', 'vendor', 'node_modules']

set :file_permissions_users, ['www-data'] set :webserver_user, "www-data"

Output styling.

set :format, :airbrussh

set :keep_releases, 5 set :branch, "masterhome"

Running npm tasks

after "deploy:symlink:release", "acl:cache"

namespace :acl do desc "Gives cache rights" task :cache do on roles(:web) do puts "\n\n=== Gives correct ... to cache folder ===\n\n" execute "sh #{deploy_to}/postinstall.sh" end end end`

Some more info is that the symfony cache directory is part of the deploy and is not a shared folder. I'm also running npm and gulp in my composer.json to build assets in the dist dir, with a manifest.

Anyone has a clue about this ? Any help much appreciated!

Nyholm commented 5 years ago

I’ve also seen this problem time to time. I always assumed it was a class loader cache problem. So I got this error for some requests between deploy and my “post deploy cache clear hook”.

What did you find?

ChoppyThing commented 5 years ago

So i did take some time to fix this but my problem was linked to another problem : See here

As explained, my case was that i used a third party bundle which needed a writable cache folder at runtime. Later on i was setting acl for my cache folder after composer install, which was too late. To solve this I manually create the cache folder before composer install and gives it the correct access rights. This seems to work correctly.

There might be better solutions.

Nyholm commented 5 years ago

Thank you for reporting back on this.