and proc_reload_file () =
if !debug then Syslog.notice "remote call: reload_file";
- try reload_file (); `ok
+ try reload_files (); `ok
with Failure err -> `error err
and proc_set_variable (name, value) =
with
Failure msg -> `error msg
-(* Reload the jobs file. *)
-and reload_file () =
- let file = sprintf "%s/jobs.cmo" !jobsdir in
+(* Reload the jobs file(s). *)
+and reload_files () =
+ (* Get dir/*.cmo *)
+ let dir = !jobsdir in
+ let files = Array.to_list (Sys.readdir dir) in
+ let files = List.filter (
+ fun file ->
+ let n = String.length file in
+ n >= 5 && String.sub file (n-4) 4 = ".cmo"
+ ) files in
+ let files = List.map (fun file -> dir // file) files in
+ let files = List.sort compare files in
(* As we are reloading the file, we want to create a new state
* that has no jobs, but has all the variables from the previous
let s =
try
- Dynlink.loadfile file;
+ List.iter Dynlink.loadfile files;
let s = Whenfile.get_state () in
- Syslog.notice "loaded %d job(s) from %s" (Whenstate.nr_jobs s) file;
+ Syslog.notice "loaded %d job(s) from %d file(s)"
+ (Whenstate.nr_jobs s) (List.length files);
s
with
| Dynlink.Error err ->