Skip to content

anonymous /srv.erl
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
-module(srv).
-behaviour(gen_server).
-compile(export_all).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
start() ->
gen_server:start({global, ?MODULE}, ?MODULE, [], []).
init(_) ->
{ok, []}.
handle_call(ping, _From, State) ->
io:format("# pong~n"),
{reply, ok, State};
handle_call(_Request, _From, State) ->
{reply, ok, State}.
handle_cast(_Msg, State) ->
{noreply, State}.
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
-module(tst).
-behaviour(gen_server).
-compile(export_all).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
start(SrvNode) ->
gen_server:start({local, ?MODULE}, ?MODULE, SrvNode, []).
init(SrvNode) ->
ping_srv(SrvNode),
{ok, []}.
ping_srv(SrvNode) ->
net_adm:ping(SrvNode),
global:sync(),
T1 = now(),
gen_server:call({global, srv}, ping),
io:format("# ~p ms.~n", [timer:now_diff(now(), T1)/1000]).
handle_call(_Request, _From, State) ->
{reply, ok, State}.
handle_cast(_Msg, State) ->
{noreply, State}.
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.