This commit is contained in:
parent
6b5a127b1f
commit
ad02ba0fe5
2 changed files with 16 additions and 11 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
let src = Logs.Src.create "server"
|
let src = Logs.Src.create "unikernel server"
|
||||||
|
|
||||||
module Log = (val Logs.src_log src : Logs.LOG)
|
module Log = (val Logs.src_log src : Logs.LOG)
|
||||||
module Method = Mte.Method
|
module Method = Mte.Method
|
||||||
|
|
|
||||||
|
|
@ -276,20 +276,25 @@ struct
|
||||||
let (`Initialized th) = Paf.serve http_1_1_service http_server in
|
let (`Initialized th) = Paf.serve http_1_1_service http_server in
|
||||||
th
|
th
|
||||||
|
|
||||||
let test_pgx { pgx_database; pgx_port; pgx_hostname; pgx_user; pgx_password }
|
|
||||||
pgx () =
|
|
||||||
let module Pgx = (val pgx : Pgx_lwt.S) in
|
|
||||||
Pgx.with_conn ~user:pgx_user ~host:pgx_hostname ~password:pgx_password
|
|
||||||
~port:pgx_port ~database:pgx_database (fun _conn ->
|
|
||||||
Logs.info (fun m -> m "Pgx.with_conn callback~~");
|
|
||||||
Lwt.return_unit)
|
|
||||||
|
|
||||||
let start assets_ro certificate_ro key_ro tcpv4v6 http_server stack
|
let start assets_ro certificate_ro key_ro tcpv4v6 http_server stack
|
||||||
happy_eyeballs pgx_setup =
|
happy_eyeballs pgx_setup =
|
||||||
let open Lwt.Syntax in
|
Logs.set_reporter (Logs_fmt.reporter ());
|
||||||
Logs.(set_level (Some Info));
|
Logs.(set_level (Some Info));
|
||||||
|
let open Lwt.Syntax in
|
||||||
let pgx = Pgx_mirage.connect (stack, happy_eyeballs) in
|
let pgx = Pgx_mirage.connect (stack, happy_eyeballs) in
|
||||||
let* () = test_pgx pgx_setup pgx () in
|
let module Pgx = (val pgx : Pgx_lwt.S) in
|
||||||
|
let { pgx_database; pgx_port; pgx_hostname; pgx_user; pgx_password } =
|
||||||
|
pgx_setup
|
||||||
|
in
|
||||||
|
Pgx.with_conn ~user:pgx_user ~host:pgx_hostname ~password:pgx_password
|
||||||
|
~port:pgx_port ~database:pgx_database
|
||||||
|
@@ fun conn ->
|
||||||
|
let* () =
|
||||||
|
let+ alive = Pgx.alive conn in
|
||||||
|
match alive with
|
||||||
|
| false -> Fmt.failwith "Pgx connection failure: connection not alive"
|
||||||
|
| true -> Logs.info (fun m -> m "Pgx connection success")
|
||||||
|
in
|
||||||
let* assets_res = Assets.assets assets_ro in
|
let* assets_res = Assets.assets assets_ro in
|
||||||
match assets_res with
|
match assets_res with
|
||||||
| Error (`Msg m) -> Fmt.failwith "Assets configuration error: %s." m
|
| Error (`Msg m) -> Fmt.failwith "Assets configuration error: %s." m
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue