blob: c2270dd244e9830b55af21d3b7ce3df7ca1700a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
open Lwt
open Defaults
open Vyconf_config
let () = Lwt_log.add_rule "*" Lwt_log.Info
(* Default VyConf configuration *)
let daemonize = ref true
let config_file = ref defaults.config_file
let log_file = ref None
let log_template = ref "$(date): $(message)"
(* Global data *)
(* Command line arguments *)
let args = [
("--no-daemon", Arg.Unit (fun () -> daemonize := false),
"Do not daemonize");
("--config", Arg.String (fun s -> config_file := s),
(Printf.sprintf "<string> Configuration file, default is %s" defaults.config_file));
("--log-file", Arg.String (fun s -> log_file := Some s),
"<string> Log file");
("--version", Arg.Unit (fun () -> print_endline @@ Version.version_info (); exit 0), "Print version and exit")
]
let usage = "Usage: " ^ Sys.argv.(0) ^ " [options]"
let main_loop config () =
let%lwt () = Startup.setup_logger !daemonize !log_file !log_template in
let%lwt () = Lwt_log.notice @@ Printf.sprintf "Starting VyConf for %s" config.app_name in
Lwt.return_unit
let () =
let () = Arg.parse args (fun f -> ()) usage in
let config = Startup.load_config !config_file in
let dirs = Directories.make config in
Startup.check_dirs dirs;
Lwt_main.run @@ main_loop config ()
|