Created
September 26, 2017 02:40
-
-
Save elbrujohalcon/d69224c97396017d923776c2b212cebe to your computer and use it in GitHub Desktop.
Maybe Server v3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(maybe_server). | |
-behaviour(gen_server). | |
-export([start_link/0, stop/0]). | |
-export([init/1, terminate/2, handle_call/3, handle_cast/2]). | |
%% EXTERNAL API ------------------------------------------------------------------------------------ | |
start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, #{}, [{debug, [log, trace]}]). | |
stop() -> gen_server:stop(?MODULE). | |
%% CALLBACKS --------------------------------------------------------------------------------------- | |
init(#{}) -> | |
error_logger:info_msg("Server ~p starting.~n", [self()]), | |
process_flag(trap_exit, true), | |
{ok, #{}}. | |
terminate(Reason, _State) -> | |
error_logger:info_msg("Server ~p terminating with reason ~p~n", [self(), Reason]). | |
%% UNUSED CALLBACKS -------------------------------------------------------------------------------- | |
handle_call(_Msg, _From, State) -> {noreply, State}. | |
handle_cast(_Msg, State) -> {noreply, State}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment