File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1212require __DIR__ . '/deploy/lock.php ' ;
1313require __DIR__ . '/deploy/push.php ' ;
1414require __DIR__ . '/deploy/release.php ' ;
15+ require __DIR__ . '/deploy/reset_opcache.php ' ;
1516require __DIR__ . '/deploy/rollback.php ' ;
1617require __DIR__ . '/deploy/setup.php ' ;
1718require __DIR__ . '/deploy/shared.php ' ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Deployer ;
4+
5+ set ('reset_opcache_nonce ' , bin2hex (random_bytes (8 )));
6+ set ('reset_opcache_document_root ' , '{{release_or_current_path}} ' );
7+ set ('reset_opcache_app_url ' , 'https://{{hostname}} ' );
8+
9+ desc ('Place PHP OPcache Reset Script ' );
10+ task ('deploy:reset_opcache:prepare ' , function () {
11+ $ phpScript = <<<PHP
12+ <?php
13+ if (function_exists("clearstatcache")) {
14+ clearstatcache(true); // Clear realpath cache
15+ }
16+ if (function_exists("opcache_reset")) {
17+ opcache_reset(); // Clear opcache
18+ }
19+ @unlink(__FILE__);
20+ echo "success";
21+ PHP ;
22+
23+ run ('echo "$PHP_OPCACHE_RESET_SCRIPT" > {{reset_opcache_document_root}}/reset_opcache-{{reset_opcache_nonce}}.php ' , env: ['PHP_OPCACHE_RESET_SCRIPT ' => $ phpScript ]);
24+ });
25+
26+ desc ('Execute PHP OPcache Reset ' );
27+ task ('deploy:reset_opcache:execute ' , function () {
28+ $ result = fetch ("{{reset_opcache_app_url}}/reset_opcache-{{reset_opcache_nonce}}.php " );
29+ if ($ result !== 'success ' ) {
30+ throw error ('Reset PHP OPcache failed! ' );
31+ }
32+ });
33+
34+ desc ('Reset PHP OPcache ' );
35+ task ('deploy:reset_opcache ' , [
36+ 'deploy:reset_opcache:prepare ' ,
37+ 'deploy:reset_opcache:execute ' ,
38+ ]);
You can’t perform that action at this time.
0 commit comments