assert false
and daemon_status () =
- assert false
+ let r =
+ try
+ let client = start_client_no_exit () in
+ let r = Whenproto_clnt.When.V1.ping_daemon client () in
+ stop_client client;
+ r = `ok
+ with
+ exn -> false in
+ print_endline (if r then "up" else "down")
and jobs () =
let client = start_client () in
and start_client () =
let addr = sprintf "%s/socket" jobsdir in
let client =
- try
- Whenproto_clnt.When.V1.create_client
- (Rpc_client.Unix addr)
- Rpc.Tcp (* not TCP, this is the same as SOCK_STREAM *)
+ try start_client_no_exit ()
with
| Unix_error ((ECONNREFUSED|ENOENT), _, _) ->
eprintf "whenjobs: error: the daemon ('whenjobsd') is not running\n";
exit 1 in
client
+and start_client_no_exit () =
+ let addr = sprintf "%s/socket" jobsdir in
+ Whenproto_clnt.When.V1.create_client
+ (Rpc_client.Unix addr)
+ Rpc.Tcp (* not TCP, this is the same as SOCK_STREAM *)
+
and stop_client client =
Rpc_client.shut_down client