diff options
Diffstat (limited to 'src/ucs.ml')
-rw-r--r-- | src/ucs.ml | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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 |