(** Server startup. Loads configuration, then hands the resulting routes to Dream. Startup fails loudly rather than falling back to defaults, so a typo in a config file is noticed immediately instead of silently changing which repositories are served. The one exception is an explicit [git_project_root] on the command line, which is enough on its own to run without any config file. *) let run_with_config config = Dream.run ~port:config.Config.port ~interface:config.Config.host @@ Dream.logger @@ Dream.router (Handlers.routes config) let run ?git_project_root () = let config = match Config.load () with | Ok config -> config | Error error -> if Option.is_some git_project_root then Config.default else failwith (Config.show_load_error error) in let config = match git_project_root with | Some path -> { config with git_project_root = path } | None -> config in run_with_config config