tweak opcache preload a bit

This commit is contained in:
Bradley W Dutton 2020-11-30 20:08:51 -08:00
parent 3f3e64511b
commit c8397c5d37

View File

@ -20,7 +20,9 @@
function getfiles( $path , &$files = array() ) { function getfiles( $path , &$files = array() ) {
if ( !is_dir( $path ) ) return null; if ( !is_dir( $path ) ) return null;
$handle = opendir( $path ); $handle = opendir( $path );
while ( false !== ( $file = readdir( $handle ) ) ) { while ( false !== ( $file = readdir( $handle ) ) ) {
if ( $file != '.' && $file != '..' ) { if ( $file != '.' && $file != '..' ) {
$path2 = $path . '/' . $file; $path2 = $path . '/' . $file;
@ -33,10 +35,15 @@ function getfiles( $path , &$files = array() ) {
} }
} }
} }
closedir($handle);
return $files; return $files;
} }
$preload_dirs = [ $preload_dirs = [
'vendor/lsolesen/pel/src',
'vendor/phpmailer/phpmailer/src',
'application', 'application',
'system', 'system',
'modules/gallery', 'modules/gallery',
@ -50,12 +57,25 @@ $br = "\n";
foreach ($preload_dirs as $dir) { foreach ($preload_dirs as $dir) {
$files = []; $files = [];
$full_dir = "/var/www/$dir"; $full_dir = "/var/www/$dir";
getfiles($full_dir, $files); getfiles($full_dir, $files);
sort($files);
echo "opcache preload ".count($files)." files from $full_dir\n"; echo "opcache preload ".count($files)." files from $full_dir\n";
foreach ($files as $file) { foreach ($files as $file) {
if ($dir == 'modules') {
# don't load the second time through the list
if (preg_match('#^/var/www/modules/gallery/#', $file)) continue;
}
if (preg_match('#^/var/www/modules/gallery/tests#', $file)) continue;
if (preg_match('#^/var/www/modules/gallery_unit_test#', $file)) continue;
echo $file.$br; echo $file.$br;
opcache_compile_file($file); opcache_compile_file($file);
} }
echo "\n";
} }