builder-web/bin/builder_web_app.ml
Reynir Björnsson 8d211dc831 Check database version
Exit if the application id and user version are not as expected.
2021-02-17 14:15:57 +01:00

19 lines
544 B
OCaml

open Opium
let app t =
App.empty
|> App.cmd_name "Builder Web"
|> Builder_web.add_routes t
let () =
let () = Mirage_crypto_rng_unix.initialize () in
let datadir = Fpath.v "/var/db/builder-web/" in
match Builder_web.init "/var/db/builder-web/builder.sqlite3" datadir with
| Error (#Caqti_error.load as e) ->
Format.eprintf "Error: %a\n" Caqti_error.pp e;
| Error (#Builder_web.db_error | `Wrong_version _ as e) ->
Format.eprintf "Error: %a\n" Builder_web.pp_error e;
exit 1
| Ok t ->
App.run_command (app t)