File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed
example/z-playground/server Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -479,12 +479,6 @@ let rec gc ?(initial = true) () =
479479let () =
480480 Dream. log " Starting playground" ;
481481
482- (* Stop when systemd sends SIGTERM. *)
483- let stop, signal_stop = Lwt. wait () in
484- Lwt_unix. on_signal Sys. sigterm (fun _signal ->
485- Lwt. wakeup_later signal_stop () )
486- |> ignore;
487-
488482 (* Build the base image. *)
489483 Lwt_main. run begin
490484 Lwt_io. (with_file ~mode: Output " Dockerfile" (fun channel ->
@@ -520,7 +514,7 @@ let () =
520514 Dream. html (Client. html example)
521515 in
522516
523- Dream. run ~interface: " 0.0.0.0" ~port: 80 ~stop ~ adjust_terminal:false
517+ Dream. run ~interface: " 0.0.0.0" ~port: 80 ~adjust_terminal: false
524518 @@ Dream. logger
525519 @@ Dream. router [
526520
Original file line number Diff line number Diff line change @@ -2129,7 +2129,7 @@ val run :
21292129 - [~stop] is a promise that causes the server to stop accepting new
21302130 requests, and {!Dream.run} to return. Requests that have already entered
21312131 the Web application continue to be processed. The default value is a
2132- promise that never resolves.
2132+ promise that resolves when the [TERM] signal is received .
21332133 - [~error_handler] handles all errors, both from the application, and
21342134 low-level errors. See {!section-errors} and example
21352135 {{:https://github.com/aantron/dream/tree/master/example/9-error#folders-and-files}
Original file line number Diff line number Diff line change @@ -668,7 +668,10 @@ let serve_with_maybe_https
668668
669669let default_interface = " localhost"
670670let default_port = 8080
671- let never = fst (Lwt. wait () )
671+ let on_sigterm =
672+ let promise, resolve = Lwt. wait () in
673+ ignore (Lwt_unix. on_signal Sys. sigterm (fun _ -> Lwt. wakeup_later signal_stop () ));
674+ promise
672675
673676let network ~port ~socket_path =
674677 match socket_path with
@@ -679,7 +682,7 @@ let serve
679682 ?(interface = default_interface)
680683 ?(port = default_port)
681684 ?socket_path
682- ?(stop = never )
685+ ?(stop = on_sigterm )
683686 ?(error_handler = Error_handler. default)
684687 ?(tls = false )
685688 ?certificate_file
@@ -707,7 +710,7 @@ let run
707710 ?(interface = default_interface)
708711 ?(port = default_port)
709712 ?socket_path
710- ?(stop = never )
713+ ?(stop = on_sigterm )
711714 ?(error_handler = Error_handler. default)
712715 ?(tls = false )
713716 ?certificate_file
You can’t perform that action at this time.
0 commit comments