My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Clean up stale overlay mounts at batch startup

Unmounts and removes any leaked day11_run_* temp dirs from previous
runs that were killed without cleanup. Prevents load average
spiralling from accumulated overlay mounts and kernel threads.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+21
+21
day11/bin/cmd_batch.ml
··· 162 162 ignore solutions; 163 163 (!doc_count, !doc_html) 164 164 165 + let cleanup_stale_mounts () = 166 + (* Unmount and remove any leaked day11_run_* overlay mounts from 167 + previous runs that were killed without cleanup *) 168 + let tmp = Filename.get_temp_dir_name () in 169 + let entries = try Sys.readdir tmp |> Array.to_list with _ -> [] in 170 + let stale = List.filter (fun name -> 171 + String.length name > 10 && 172 + String.sub name 0 10 = "day11_run_" 173 + ) entries in 174 + if stale <> [] then begin 175 + Printf.printf "Cleaning up %d stale temp dirs...\n%!" (List.length stale); 176 + List.iter (fun name -> 177 + let merged = Filename.concat (Filename.concat tmp name) "merged" in 178 + ignore (Sys.command (Printf.sprintf "sudo umount %s 2>/dev/null" merged)); 179 + ) stale; 180 + ignore (Sys.command (Printf.sprintf "sudo rm -rf %s" 181 + (String.concat " " (List.map (fun name -> 182 + Filename.concat tmp name) stale)))) 183 + end 184 + 165 185 let run cache_dir opam_repositories np arch os_distribution os_version 166 186 with_doc ocaml_version_str odoc_repo patches_dir opam_build_repo 167 187 solve_only dry_run rebuild_failed rebuild_base target = 188 + cleanup_stale_mounts (); 168 189 let cache_dir = Common.fpath cache_dir in 169 190 Bos.OS.Dir.create ~path:true cache_dir |> ignore; 170 191 let ocaml_version = Common.parse_ocaml_version ocaml_version_str in