aboutsummaryrefslogtreecommitdiff
path: root/src/ucs.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/ucs.ml')
-rw-r--r--src/ucs.ml12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ucs.ml b/src/ucs.ml
index 3b6027c..84d5988 100644
--- a/src/ucs.ml
+++ b/src/ucs.ml
@@ -49,7 +49,17 @@ let () =
mode = match socket with
| Some s -> `Unix_domain_socket (`File s)
| None -> `TCP (`Port port) in
- Lwt_main.run (Server.serve base_url celcat_uri mode) in
+ let stop, r = Lwt.wait () in
+ Lwt_unix.on_signal Sys.sigint
+ (fun _ -> Lwt.wakeup r ()) |> ignore;
+ Lwt_unix.on_signal Sys.sigterm
+ (fun _ -> Lwt.wakeup r ()) |> ignore;
+ Lwt_main.run (
+ Lwt.finalize
+ (fun () -> Server.serve base_url celcat_uri mode stop)
+ (fun () -> match socket with
+ | Some s -> Lwt_unix.unlink s
+ | None -> Lwt.return_unit)) in
let cmd =
let doc = "micro celcatsanitizer: convert celcat \
calendar to ICS files, on the fly." and