Start tty logger if headless, check config for duplicate ids
This commit is contained in:
@@ -45,6 +45,7 @@ stop(_State) ->
|
||||
ok.
|
||||
|
||||
set_things_up() ->
|
||||
maybe_add_logger_handler(),
|
||||
gmhc_counters:initialize(),
|
||||
gmhc_config:load_config(),
|
||||
logger:set_module_level([gmhw_pow_cuckoo], notice),
|
||||
@@ -59,3 +60,16 @@ set_things_up() ->
|
||||
_ -> ok
|
||||
end,
|
||||
ok.
|
||||
|
||||
maybe_add_logger_handler() ->
|
||||
case is_headless() orelse application:get_env(gmhive_client, tty_logger, false) of
|
||||
true ->
|
||||
Level = application:get_env(gmhive_client, tty_logger_level, error),
|
||||
io:fwrite("Adding logger handler: ~p~n", [Level]),
|
||||
logger:add_handler(gmhc_tty, logger_std_h, #{level => Level});
|
||||
false ->
|
||||
ok
|
||||
end.
|
||||
|
||||
is_headless() ->
|
||||
undefined == application:get_key(gajumine, vsn).
|
||||
|
||||
@@ -14,8 +14,20 @@ load_config() ->
|
||||
gmconfig:apply_os_env(),
|
||||
gmconfig:process_plain_args(),
|
||||
check_application_env(),
|
||||
check_final_config(),
|
||||
ok.
|
||||
|
||||
check_final_config() ->
|
||||
ExtraPubkeys = get_config([<<"extra_pubkeys">>]),
|
||||
AllKeys = [get_config([<<"pubkey">>]) | ExtraPubkeys],
|
||||
case AllKeys -- lists:usort(AllKeys) of
|
||||
[] ->
|
||||
ok;
|
||||
Duplicates ->
|
||||
?LOG_ERROR("Duplicate account ids found: ~p", [Duplicates]),
|
||||
error({duplicate_account_ids, Duplicates})
|
||||
end.
|
||||
|
||||
instrument_gmconfig() ->
|
||||
gmconfig:set_gmconfig_env(gmconfig_env()).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user