mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-07-14 02:50:13 -04:00
add generic opcache preloader for PHP 7.4 docker container
This commit is contained in:
42
lib/preload_opcache.php
Normal file
42
lib/preload_opcache.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
function getfiles( $path , &$files = array() ) {
|
||||
if ( !is_dir( $path ) ) return null;
|
||||
$handle = opendir( $path );
|
||||
while ( false !== ( $file = readdir( $handle ) ) ) {
|
||||
if ( $file != '.' && $file != '..' ) {
|
||||
$path2 = $path . '/' . $file;
|
||||
if ( is_dir( $path2 ) ) {
|
||||
getfiles( $path2 , $files );
|
||||
} else {
|
||||
if ( preg_match( "/\.(php|php5)$/i" , $file ) ) {
|
||||
$files[] = $path2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
$preload_dirs = [
|
||||
'application',
|
||||
'system',
|
||||
'modules',
|
||||
'themes',
|
||||
];
|
||||
|
||||
$br = (php_sapi_name() == "cli") ? "\n" : "<br />";
|
||||
$br = "\n";
|
||||
|
||||
foreach ($preload_dirs as $dir) {
|
||||
$files = [];
|
||||
$full_dir = "/var/www/$dir";
|
||||
getfiles($full_dir, $files);
|
||||
|
||||
echo "opcache preload ".count($files)."files from $full_dir\n";
|
||||
|
||||
foreach ($files as $file) {
|
||||
echo $file.$br;
|
||||
opcache_compile_file($file);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user