getMessage() . "\n" . $e->getTraceAsString(), FILE_APPEND); throw $e; } }); function _config_worker_run_procs(ConfigFetchParams $params, array $jobs, bool $serial) : array { if($serial) { $results_by_job = array(); foreach($jobs as $job) $results_by_job[] = _config_worker_func($params, $job); return $results_by_job; } else { $worker_args = array(); foreach($jobs as $idx => $job) $worker_args[] = array($params, $job); return run_background_gamectl_workers('config_worker', $worker_args); } } //returns [[base_dir, file, cache_file, was_stale], ...] function _config_worker_func(ConfigFetchParams $params, array $job) : array { $start_time = microtime(true); $params->globals->initWorker(); list($idx, $start_time, $chunk) = $job; if($params->verbose) echo "[CFG] Worker $idx (" . sizeof($chunk) . ") started (".round(microtime(true)-$start_time, 2)." sec)\n"; $fast_parser_num = 0; $results = array(); foreach($chunk as $file_idx => $chunk_data) { try { list($base_dir, $file) = $chunk_data; if($params->verbose && $file_idx > 0 && ($file_idx % 500) == 0) echo "[CFG] Worker $idx progress: " . round($file_idx / sizeof($chunk) * 100) . "% ...\n"; $cache_file = config_get_cache_path($params->globals, $file); $parser_type = null; $is_stale = true; if(!$params->force_stale) $is_stale = need_to_regen($cache_file, array($file)); if($is_stale) _config_invalidate_cache($params, $base_dir, $file, $cache_file, $parser_type); $results[] = array($base_dir, $file, $cache_file, $is_stale, $parser_type); } catch(Exception $e) { throw new Exception("Error in file '$file': " . $e->getMessage()); } } if($params->verbose) echo "[CFG] Worker $idx done (".round(microtime(true)-$start_time, 2)." sec)\n"; return $results; }