Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SUPERVISOR
- start_link() ->
- supervisor:start_link(superv, []).
- init(_Args) ->
- {ok, {{one_for_one, 1, 1}, % 60
- [{server, {server, start_link, []},
- permanent, brutal_kill, worker, [server]}]}}.
- SERVER
- start_link() ->
- gen_server:start_link({local, server}, ?MODULE, [], []).
- init(_Args) ->
- io:format("Server init\n"),
- case database:init() of
- {aborted,{already_exists,entity}} -> {ok, database:select_all()};
- _ -> {ok, addressBook:createAddressBook()}
- end.
- DATABASE
- select_all() ->
- {atomic, Book} = mnesia:transaction(
- fun() ->
- qlc:eval(qlc:q([ X || X <- mnesia:table(entity) ]))
- end
- ),
- Book.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement