(paths: &PglitePaths, runtime_layout: &RuntimeLayout)
| 2233 | } |
| 2234 | |
| 2235 | fn run_split_initdb(paths: &PglitePaths, runtime_layout: &RuntimeLayout) -> Result<()> { |
| 2236 | let _phase = timing::phase("initdb.split_wasix"); |
| 2237 | let initdb_module = runtime_layout.module_root.join("bin/initdb"); |
| 2238 | let postgres_module = runtime_layout.module_root.join("bin/postgres"); |
| 2239 | ensure!( |
| 2240 | initdb_module.exists(), |
| 2241 | "split WASIX initdb module is not installed at {}; regenerate assets with `xtask assets template`", |
| 2242 | initdb_module.display() |
| 2243 | ); |
| 2244 | ensure!( |
| 2245 | postgres_module.exists(), |
| 2246 | "WASIX postgres module is not installed at {}", |
| 2247 | postgres_module.display() |
| 2248 | ); |
| 2249 | |
| 2250 | fs::create_dir_all(&paths.pgdata) |
| 2251 | .with_context(|| format!("create fresh PGDATA {}", paths.pgdata.display()))?; |
| 2252 | |
| 2253 | let (engine, _) = aot::load_runtime_module()?; |
| 2254 | let process_runtime = process_wasix_runtime(&engine)?; |
| 2255 | seed_wasix_module_cache( |
| 2256 | &process_runtime.tokio_runtime, |
| 2257 | &engine, |
| 2258 | &process_runtime.wasix_module_cache, |
| 2259 | &initdb_module, |
| 2260 | "tool:initdb", |
| 2261 | "split initdb command", |
| 2262 | )?; |
| 2263 | seed_wasix_module_cache( |
| 2264 | &process_runtime.tokio_runtime, |
| 2265 | &engine, |
| 2266 | &process_runtime.wasix_module_cache, |
| 2267 | &postgres_module, |
| 2268 | "runtime:pglite", |
| 2269 | "initdb child postgres command", |
| 2270 | )?; |
| 2271 | preload_runtime_side_modules( |
| 2272 | &process_runtime.tokio_runtime, |
| 2273 | &engine, |
| 2274 | &process_runtime.wasix_module_cache, |
| 2275 | &runtime_layout.module_root, |
| 2276 | )?; |
| 2277 | // initdb execs child postgres commands; isolate that command process tree |
| 2278 | // from concurrently running backends while keeping the module cache shared. |
| 2279 | let initdb_runtime = build_wasix_runtime( |
| 2280 | &process_runtime.tokio_runtime, |
| 2281 | &engine, |
| 2282 | process_runtime.wasix_module_cache.clone(), |
| 2283 | ); |
| 2284 | |
| 2285 | let package = split_initdb_binary_package(&initdb_module, &postgres_module)?; |
| 2286 | let root_fs = split_initdb_root_filesystem(paths, runtime_layout)?; |
| 2287 | root_fs |
| 2288 | .read_dir(Path::new(PGDATA_DIR)) |
| 2289 | .with_context(|| format!("verify split initdb {PGDATA_DIR} mount"))?; |
| 2290 | |
| 2291 | let (stdout_file, stdout_capture) = TailCaptureFile::new(8 * 1024); |
| 2292 | let (stderr_file, stderr_capture) = TailCaptureFile::new(8 * 1024); |
no test coverage detected