Re: PHP-FPM: How to clear the realpath cache on deployment?

From: Date: Fri, 19 Jun 2015 15:46:19 +0000
Subject: Re: PHP-FPM: How to clear the realpath cache on deployment?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-86759@lists.php.net to get a copy of this message
On 06/19/2015 08:43 AM, Sebastian Bergmann wrote: > Scenario: nginx + PHP-FPM / FastCGI. > > The final step of the deployment is updating a symlink to point to the > new version. > > For N <= realpath_cache_ttl seconds after the deployment, some > filesystem operations fail because of outdated realpath cache entries. > > Is there a way to signal the PHP-FPM / FastCGI processes to clear > the realpath cache? If not, I think this should be added :-) I think this is a symptom of doing deploys incorrectly. If you are flipping a symlink on a live server which can happen in the middle of a request then your deploy mechanism is broken. The web server should set the document_root to the target of the symlink at the start of a request. For nginx this is a built-in feature: fastcgi_param DOCUMENT_ROOT $realpath_root; For Apache I wrote a module to do it: https://github.com/etsy/mod_realdoc Then there is never a question of needing to clear any caches at the PHP level. See: https://codeascraft.com/2013/07/01/atomic-deploys-at-etsy/ for a more indepth explanation. -Rasmus

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#86759) next »