File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,10 @@ let default =
79
79
80
80
include Httpev_common
81
81
82
+ type http_server_bind =
83
+ | Systemd of Lwt_unix .file_descr
84
+ | Connection of Unix .sockaddr
85
+
82
86
type partial_body = {
83
87
line1 : string ;
84
88
content_length : int option ;
@@ -1119,6 +1123,24 @@ let setup_lwt config answer =
1119
1123
let server_lwt config answer =
1120
1124
Lwt_main. run @@ setup_lwt config answer
1121
1125
1126
+ let setup_bind_lwt addr config answer =
1127
+ let connection =
1128
+ match addr, Systemd.Daemon. listen_fds_lwt () with
1129
+ | None , [] -> Exn. fail " bind not provided and no systemd socket available"
1130
+ | None , fd :: fds ->
1131
+ if fds <> [] then
1132
+ log#warn " more than one fd is provided by systemd, only the first one is used and the other ones are ignored" ;
1133
+ Systemd fd
1134
+ | Some addr , _ -> Connection addr
1135
+ in
1136
+ match connection with
1137
+ | Systemd fd ->
1138
+ log#info " starting httpev in systemd mode" ;
1139
+ setup_fd_lwt fd config answer
1140
+ | Connection connection ->
1141
+ log#info " starting httpev on %s" (Nix. show_addr connection);
1142
+ setup_lwt { config with connection } answer
1143
+
1122
1144
module Answer = struct
1123
1145
1124
1146
let return ?(status =`Ok ) ?(extra =[] ) ~typ data : [> `Body of reply_status reply' ] Lwt.t =
You can’t perform that action at this time.
0 commit comments