Start tty logger if headless, check config for duplicate ids #15
@ -1,6 +1,6 @@
|
||||
{application,gmhive_client,
|
||||
[{description,"Gajumaru Hive Client"},
|
||||
{vsn,"0.6.1"},
|
||||
{vsn,"0.6.2"},
|
||||
{registered,[]},
|
||||
{applications,[kernel,stdlib,sasl,gproc,inets,ssl,enoise,
|
||||
gmconfig,gmhive_protocol,gmhive_worker]},
|
||||
|
||||
@ -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()).
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
{name,"gmhive_client"}.
|
||||
{type,app}.
|
||||
{modules,[]}.
|
||||
{prefix,"gmhc"}.
|
||||
{author,"Ulf Wiger, QPQ AG"}.
|
||||
{prefix,"gmhc"}.
|
||||
{desc,"Gajumaru Hive Client"}.
|
||||
{package_id,{"uwiger","gmhive_client",{0,6,1}}}.
|
||||
{package_id,{"uwiger","gmhive_client",{0,6,2}}}.
|
||||
{deps,[{"uwiger","gmhive_worker",{0,5,1}},
|
||||
{"uwiger","gmcuckoo",{1,2,4}},
|
||||
{"otpr","eblake2",{1,0,1}},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user