summaryrefslogtreecommitdiff
path: root/priv/config/rvi_common.config
blob: c8aa389c9cad18fb5fec268a5773c7e65523843c (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
%% -*- erlang -*-

%% Copyright (C) 2014, Jaguar Land Rover
%%
%% This program is licensed under the terms and conditions of the
%% Mozilla Public License, version 2.0.  The full text of the
%% Mozilla Public License is at https://www.mozilla.org/MPL/2.0/
%%
%% Configuration include file for rvi config files
%%
Out = filename:absname(proplists:get_value(outdir, OPTIONS)).
LagerRoot = Out ++ "/log/lager".
LagerDebugFmt = [time,"<",module,"/",line,">",message,"\n"].

%% Parameters for simpler modification
Env = fun(V, Def) ->
              case os:getenv(V) of
                  false -> Def;
                  Str when is_integer(Def) -> list_to_integer(Str);
                  Str when is_atom(Def) -> list_to_atom(Str);
                  Str -> Str
              end
      end.

LogLevel = Env("RVI_LOGLEVEL", info).
[
 %% All erlang apps needed to fire up a node. Do not touch.
 {apps,
  [kernel,
   stdlib,
   sasl,
   setup,
   syntax_tools,
   goldrush,
   lager,
   %% ale,
   crypto,
   public_key,
   gproc,
   base64url,
   uart,
   jsx,
   exo,
   gsms,
   compiler,
   ssl,
   asn1,
   %% RVI-specific apps.

   %% Do not touch unless you are replacing apps with your own
   %% version.  If you are replacing an app with a non-Erlang version,
   %% it still has to be loaded in order to resolve.
   %% If, for example, you want to deploy your own scheduler
   %% outside Erlang, replace
   %%
   %%     schedule,
   %% with
   %%     { schedule, load },
   %%
   rvi_core,
   rvi_common,
   service_discovery,
   service_edge,
   authorize,
   schedule,
   bt,
   dlink,
   dlink_tcp,
   dlink_tls,
   dlink_bt,
   dlink_sms,
   proto_bert,
   proto_json,
   proto_msgpack
   %% If adding apps, you can still include this config, and complement
   %% with {add_apps, [App]}, {remove_apps, [App]} and even {sort_app,A,Before}.
  ]},

 {env,
  [
   {setup,
    [
     {home, Out}
    ]},
   {lager,
    [
     {log_root, LagerRoot},
     {crash_log, "crash.log"},
     {handlers,
      [{lager_console_backend,
        [LogLevel, {rvi_lager_formatter,
                    [{debug, LagerDebugFmt}]}
        ]},
       {lager_file_backend, [{file, "error.log"}, {level, error}]},
       {lager_file_backend, [{file, "console.log"}, {level, LogLevel},
			     {formatter, rvi_lager_formatter},
			     {formatter_config, [{debug, LagerDebugFmt}]}]}
      ]},
     {extra_sinks,
      [
       {rvi_log_log_lager_event,
	[{handlers,
	  [{lager_file_backend, [{file,"rvi_log.log"},{level,info},
				{formatter, lager_default_formatter},
				 {formatter_config,
				  [time, " ", message, "\n"]}
				]}
	  ]}
	]}
      ]}
    ]},
   %% {ale,
   %%  [{init_traces, [ {[{module,rvi_log},
   %% 		       {sink, rvi_log_log_lager_event}], info, LagerRoot ++ "/rvi_log.log"} ]}]
   %% },
   {rvi_core,
    [
     {device_key, "$PRIV_DIR/keys/device_key.pem"},
     {device_cert, "$PRIV_DIR/certificates/device_cert.crt"},
     {root_cert, "$PRIV_DIR/certificates/root_cert.crt"},
     {cred_dir, "$PRIV_DIR/credentials"}
    ]}
  ]}
].