%%% @doc %%% GajuDesk %%% @end -module(gajudesk). -vsn("0.6.6"). -behavior(application). -author("Craig Everett "). -copyright("QPQ AG "). -license("GPL-3.0-or-later"). -export([ts/0]). -export([start/2, stop/1]). -export_type([id/0, key/0, poa/0, tx/0, ts/0, key_txs/0]). -include("$zx_include/zx_logger.hrl"). -include("gd.hrl"). -type id() :: binary(). -type key() :: #key{}. -type poa() :: #poa{}. -type tx() :: #tx{}. -type ts() :: integer(). -type chain_txs() :: #{ChainID :: binary() := [tx()]}. -type key_txs() :: #{id() := {{LastCheck :: ts(), mdw | node}, chain_txs()}}. ts() -> erlang:system_time(nanosecond). -spec start(normal, Args :: term()) -> {ok, pid()}. %% @private %% Called by OTP to kick things off. This is for the use of the "application" part of %% OTP, not to be called by user code. %% %% NOTE: %% The commented out second argument would come from ebin/gajudesk.app's 'mod' %% section, which is difficult to define dynamically so is not used by default %% here (if you need this, you already know how to change it). %% %% Optional runtime arguments passed in at start time can be obtained by calling %% zx_daemon:argv/0 anywhere in the body of the program. %% %% See: http://erlang.org/doc/apps/kernel/application.html start(normal, _Args) -> ok = case net_kernel:stop() of ok -> log(info, "SAFE: This node is running standalone."); {error, not_found} -> log(warning, "SAFETY: Distribution has been disabled on this node."); {error, not_allowed} -> ok = tell(error, "DANGER! This node is in distributed mode!"), init:stop(1) end, ok = application:ensure_started(hakuzaru), ok = application:ensure_started(zxwidgets), ok = application:ensure_started(sophia), gd_sup:start_link(). -spec stop(term()) -> ok. %% @private %% Similar to start/2 above, this is to be called by the "application" part of OTP, %% not client code. Causes a (hopefully graceful) shutdown of the application. stop(_State) -> ok.