Add 'whenjobs --tail <serial>' to tail output messages from jobs.
[whenjobs.git] / daemon / daemon.ml
index 925ad7e..6e6a5fd 100644 (file)
@@ -78,6 +78,7 @@ let rec init j d =
       ~proc_get_jobs
       ~proc_cancel_job
       ~proc_start_job
+      ~proc_get_job
       (Rpc_server.Unix addr)
       Rpc.Tcp (* not TCP, this is the same as SOCK_STREAM *)
       Rpc.Socket
@@ -167,6 +168,18 @@ and proc_start_job jobname =
   | Not_found -> `error "job not found"
   | exn -> `error (Printexc.to_string exn)
 
+and proc_get_job serial =
+  try
+    let serial = big_int_of_string serial in
+    let pid = BigIntMap.find serial !serialmap in
+    let job, dir, serial, start_time = IntMap.find pid !runningmap in
+    { Whenproto_aux.job_name = job.job_name;
+      job_serial = string_of_big_int serial;
+      job_tmpdir = dir; job_start_time = Int64.of_float start_time }
+  with
+  | Not_found -> failwith "job not found"
+  | exn -> failwith (Printexc.to_string exn)
+
 (* Reload the jobs file. *)
 and reload_file () =
   let file = sprintf "%s/jobs.cmo" !jobsdir in