mittwald / deployer-recipes

Collection of deployer recipes for interacting with the mittwald cloud platform
MIT License
3 stars 0 forks source link

Feature request: Clear OPcache after deployment #138

Open Starraider opened 3 months ago

Starraider commented 3 months ago

It has happened to me several times that the changes I made to my code were not visible after deployment to the SpaceServer. The first time this happened to me, after hours of unsuccessful searching for the error, I contacted Mittwald support, who then explained to me that it can happen that you have to clear the OPcache manually (by executing "touch ~/.config/php/php.ini"). Today I wasted another 20 minutes trying to figure out why my code wasn't working on the SpaceServer, until I remembered that I had forgotten to manually clear the OPcache again after deployment.

It's just super annoying and takes a ton of time, if you have to clear the OPcache manually after every deployment!!

That's why I would really like your deployer-recipes to include a function that automatically clears the OPcache after each successful deployment!

It would be great if you could add this feature!

martin-helmich commented 3 months ago

Hang on-- actually that should already happen; at least, there's a mittwald:opcache:flush task that should run after the deploy:symlink stage:

https://github.com/mittwald/deployer-recipes/blob/00d4a055c34bba1748f8702df0a8777c5a9c6a16/src/Recipes/AppRecipe.php#L124-L128

Implementation-wise, that task uses cachetool to flush the OPcache via a shell command:

https://github.com/mittwald/deployer-recipes/blob/00d4a055c34bba1748f8702df0a8777c5a9c6a16/src/Recipes/AppRecipe.php#L207-L219

Could you check if the mittwald:opcache:flush task runs on your deployment? If it does, alternatively the implementation might be flawed and cachetool doesn't flush the OPCache correctly in your case... 🤔

infabo commented 13 hours ago

https://github.com/mittwald/deployer-recipes/blob/master/src/Recipes/AppRecipe.php#L217

opcache:invalidate:scripts does not work as one would expect. It does pick up files from older release folders but ignores the ones from the most current release folder. Thus resulting in still serving outdated php files.