(* log-rotate at appropriate times *)
let write_to_stream stream =
let string = (construct_string true) in
- fprintf stream "%s\n%!" string;
+ try
+ fprintf stream "%s\n%!" string
+ with _ -> () (* Trap exception when we fail to write log *)
in
if String.length message > 0 then
(* ksprintf is the preferred name for kprintf, but the former
* is not available in OCaml 3.08.3 *)
Printf.kprintf (if b then output t level else (fun _ -> ())) fmt
-
+
let debug t (fmt: ('a , unit, string, unit) format4) = log t Debug fmt
let info t (fmt: ('a , unit, string, unit) format4) = log t Info fmt
let warn t (fmt: ('a , unit, string, unit) format4) = log t Warn fmt
access := Some (make save_to_disk)
let write_access_log ~con ~tid ?data access_type =
- Pervasiveext.maybe (fun a -> a.write access_type ~con ~tid ?data) !access
+ try
+ Pervasiveext.maybe (fun a -> a.write access_type ~con ~tid ?data) !access
+ with _ -> ()
let new_connection = write_access_log Newconn
let end_connection = write_access_log Endconn
let cf = do_argv in
let pidfile = parse_config (config_filename cf) in
- Unixext.mkdir_rec (Filename.dirname pidfile) 0o755;
+ (try
+ Unixext.mkdir_rec (Filename.dirname pidfile) 0o755
+ with _ -> ());
let rw_sock, ro_sock =
if cf.disable_socket then
if cf.daemonize then
Unixext.daemonize ();
- Unixext.pidfile_write pidfile;
+ (try
+ Unixext.pidfile_write pidfile
+ with _ -> ());
info "Xen Storage Daemon, version %d.%d"
Define.xenstored_major Define.xenstored_minor;