This commit is contained in:
Andrew Mayorov 2019-09-02 14:58:28 +03:00 committed by GitHub
parent 83fbfef475
commit 10778637e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 9 deletions

View File

@ -34,7 +34,8 @@ stop() ->
-spec init([]) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
init([]) ->
{ok, IP} = inet:parse_address(application:get_env(kds, ip, "::")),
HealthCheckers = genlib_app:env(?MODULE, health_checkers, []),
HealthCheck = genlib_app:env(?MODULE, health_check, #{}),
HealthRoute = erl_health_handle:get_route(enable_health_logging(HealthCheck)),
KeyringManagementService = woody_server:child_spec(
kds_thrift_management_service_sup,
#{
@ -47,7 +48,7 @@ init([]) ->
transport_opts => genlib_app:env(?MODULE, management_transport_opts, #{}),
protocol_opts => genlib_app:env(?MODULE, protocol_opts, #{}),
shutdown_timeout => genlib_app:env(?MODULE, shutdown_timeout, 0),
additional_routes => [erl_health_handle:get_route(HealthCheckers)]
additional_routes => [HealthRoute]
}
),
KeyringStorageService = woody_server:child_spec(
@ -62,7 +63,7 @@ init([]) ->
transport_opts => genlib_app:env(?MODULE, storage_transport_opts, #{}),
protocol_opts => genlib_app:env(?MODULE, protocol_opts, #{}),
shutdown_timeout => genlib_app:env(?MODULE, shutdown_timeout, 0),
additional_routes => []
additional_routes => [HealthRoute]
}
),
KeyringSupervisor = #{
@ -80,6 +81,11 @@ init([]) ->
],
{ok, {{one_for_one, 1, 5}, Procs}}.
-spec enable_health_logging(erl_health:check()) -> erl_health:check().
enable_health_logging(Check) ->
EvHandler = {erl_health_event_handler, []},
maps:map(fun (_, V = {_, _, _}) -> #{runner => V, event_handler => EvHandler} end, Check).
%%
%% Application callbacks

View File

@ -28,11 +28,11 @@
{keyring_storage_opts, #{
keyring_path => "/var/lib/kds/keyring"
}},
{health_checkers, [
{erl_health, disk , ["/", 99] },
{erl_health, cg_memory, [99] },
{erl_health, service , [<<"kds">>]}
]},
{health_check, #{
disk => {erl_health, disk , ["/", 99] },
memory => {erl_health, cg_memory, [99] },
service => {erl_health, service , [<<"kds">>]}
}},
{keyring_rotation_lifetime, 60000},
{keyring_initialize_lifetime, 180000},
{keyring_rekeying_lifetime, 180000},

View File

@ -15,7 +15,7 @@
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.6.0">>},2},
{<<"erl_health">>,
{git,"https://github.com/rbkmoney/erlang-health.git",
{ref,"2575c7b63d82a92de54d2d27e504413675e64811"}},
{ref,"3a80bb43a93eb0e7a940d19912d9e35c2cbe91f9"}},
0},
{<<"folsom">>,
{git,"git@github.com:folsom-project/folsom.git",