/home/runner/work/eturnal/eturnal/_build/test/cover/ct/eturnal_app.html

1 %%% eturnal STUN/TURN server.
2 %%%
3 %%% Copyright (c) 2020-2022 Holger Weiss <holger@zedat.fu-berlin.de>.
4 %%% Copyright (c) 2020-2022 ProcessOne, SARL.
5 %%% All rights reserved.
6 %%%
7 %%% Licensed under the Apache License, Version 2.0 (the "License");
8 %%% you may not use this file except in compliance with the License.
9 %%% You may obtain a copy of the License at
10 %%%
11 %%% http://www.apache.org/licenses/LICENSE-2.0
12 %%%
13 %%% Unless required by applicable law or agreed to in writing, software
14 %%% distributed under the License is distributed on an "AS IS" BASIS,
15 %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 %%% See the License for the specific language governing permissions and
17 %%% limitations under the License.
18
19 -module(eturnal_app).
20 -behaviour(application).
21 -export([start/2,
22 prep_stop/1,
23 stop/1,
24 config_change/3]).
25
26 -include_lib("kernel/include/logger.hrl").
27
28 %% API.
29
30 -spec start(application:start_type(), any()) -> {ok, pid()} | {error, term()}.
31 start(_StartType, _StartArgs) ->
32 1 ok = eturnal:init_config(),
33 1 ok = eturnal_logger:start(),
34 1 ?LOG_NOTICE("Starting eturnal ~s on Erlang/OTP ~s (ERTS ~s)",
35 [eturnal_misc:version(),
36 erlang:system_info(otp_release),
37
:-(
erlang:system_info(version)]),
38 1 case eturnal_sup:start_link() of
39 {ok, _PID} = Result ->
40 1 ok = eturnal_systemd:ready(),
41 1 Result;
42 {error, _Reason} = Err ->
43
:-(
Err
44 end.
45
46 -spec prep_stop(term()) -> term().
47 prep_stop(State) ->
48 1 ok = eturnal_systemd:stopping(),
49 1 State.
50
51 -spec stop(term()) -> ok.
52 stop(_State) ->
53 1 ?LOG_NOTICE("Stopping eturnal ~s on Erlang/OTP ~s (ERTS ~s)",
54 [eturnal_misc:version(),
55 erlang:system_info(otp_release),
56
:-(
erlang:system_info(version)]),
57 1 ok = eturnal_logger:stop().
58
59 -spec config_change([{atom(), term()}], [{atom(), term()}], [atom()]) -> ok.
60 config_change(Changed, New, Removed) ->
61
:-(
case eturnal:config_is_loaded() of
62 true ->
63
:-(
?LOG_DEBUG("Got configuration change event"),
64
:-(
ok = eturnal:reload({Changed, New, Removed},
65 fun eturnal_systemd:reloading/0,
66 fun eturnal_systemd:ready/0);
67 false ->
68
:-(
?LOG_DEBUG("Got configuration change event after release upgrade")
69 end.
Line Hits Source