Skip to content

Commit

Permalink
Merge pull request #75 from mittwald/feature-opcache-flush
Browse files Browse the repository at this point in the history
Use cachetool to selectively flush OPcache
  • Loading branch information
martin-helmich authored Feb 9, 2024
2 parents efc177a + 2ee508e commit 2b4e110
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Recipes/AppRecipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Mittwald\ApiClient\Generated\V2\Schemas\App\AppInstallation;
use Mittwald\Deployer\Client\AppClient;
use Mittwald\Deployer\Util\SanityCheck;
use function Deployer\{after, currentHost, get, info, parse, run, set, Support\starts_with, task};
use function Deployer\{after, currentHost, get, info, parse, run, set, Support\starts_with, task, test};
use function Mittwald\Deployer\get_array;
use function Mittwald\Deployer\get_str;
use function Mittwald\Deployer\get_str_nullable;
Expand Down Expand Up @@ -99,6 +99,8 @@ public static function setup(): void
'php' => '{{php_version}}',
]);

set('mittwald_local_bin', '{{ deploy_path }}/bin');

task('mittwald:discover', function (): void {
static::discover();
})
Expand Down Expand Up @@ -204,7 +206,16 @@ public static function assertDependencies(): void

public static function flushOpcache(): void
{
run('touch /etc/php/php.ini');
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");
}

}

0 comments on commit 2b4e110

Please sign in to comment.