Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Clear OPcache after deployment #138

Open
Starraider opened this issue May 16, 2024 · 3 comments
Open

Feature request: Clear OPcache after deployment #138

Starraider opened this issue May 16, 2024 · 3 comments
Assignees

Comments

@Starraider
Copy link

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
Copy link
Member

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

task('mittwald:opcache:flush', function (): void {
static::flushOpcache();
});
after('deploy:symlink', 'mittwald:opcache:flush');

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

public static function flushOpcache(): void
{
if (!test("[ -x {{ mittwald_local_bin }}/cachetool.phar ]")) {
info("downloading cachetool");
run("mkdir -p {{ mittwald_local_bin }}");
run("curl -sL https://github.com/gordalina/cachetool/releases/latest/download/cachetool.phar > {{ mittwald_local_bin }}/cachetool.phar");
run("chmod +x {{ mittwald_local_bin }}/cachetool.phar");
}
run('{{ mittwald_local_bin }}//cachetool.phar opcache:invalidate:scripts --fcgi=127.0.0.1:9000 {{ deploy_path }}');
info("opcache flushed");
}

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
Copy link

infabo commented Aug 23, 2024

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.

@martin-helmich
Copy link
Member

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.

Ooh, that would also explain the initial bug report. 💡 Thanks for the hint, I'll investigate. 👍 🕵️

@martin-helmich martin-helmich self-assigned this Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants