X-Git-Url: http://git.annexia.org/?p=whenjobs.git;a=blobdiff_plain;f=daemon%2Fdaemon.ml;h=bc4f51a2f1177e5be2692a233d7f2b850f9a55bc;hp=e18574d3bbab6bf5cf5ec346d3bb072305d5eaeb;hb=ea28f8eebc4d8434e7e66d62b769d747656d27ae;hpb=550bd0df9a6c9067dd0e2f9e77ae650efdf62454 diff --git a/daemon/daemon.ml b/daemon/daemon.ml index e18574d..bc4f51a 100644 --- a/daemon/daemon.ml +++ b/daemon/daemon.ml @@ -99,7 +99,7 @@ let rec init j d = 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) = @@ -290,9 +290,15 @@ and proc_whisper_variables vars = 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 (bytecode) or dir/*.cmxs (native code) *) + let suffix = if not Dynlink.is_native then ".cmo" else ".cmxs" in + let dir = !jobsdir in + let files = Array.to_list (Sys.readdir dir) in + let files = List.filter (fun file -> string_endswith file suffix) 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 @@ -303,9 +309,10 @@ and reload_file () = 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 ->