% escript will ignore the first line
main(_) ->
foo_srv:start_link(),
Result = foo_srv:foo(),
io:format("Result: ~p", [Result]).
-module(foo_srv).
-behaviour(gen_server).
-export([
start_link/0,
stop/0,
init/1,
handle_call/3,
handle_cast/2,
handle_info/2,
code_change/3,
terminate/2,
foo/0
]).
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
init([]) ->
{ok, []}.
stop() ->
gen_server:call(?MODULE, stop).
handle_call(_Event, _From, State) ->
{reply, bar, State};
handle_call(_Event, _From, State) ->
{noreply, State}.
handle_cast(_Event, State) ->
{noreply, State}.
handle_info(_Event, State) ->
{noreply, State}.
code_change(_OldVsc, State, _Extra) ->
{ok, State}.
terminate(Reason, _State) ->
Reason.
foo() ->
gen_server:call(?MODULE, foo).