Skip to content

Instantly share code, notes, and snippets.

Created May 18, 2009 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/113740 to your computer and use it in GitHub Desktop.
Save anonymous/113740 to your computer and use it in GitHub Desktop.
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname cli
-define(NODE, test@localhost).
main(_) ->
os:cmd("epmd -daemon"),
start(),
ping().
start() ->
Cmd = io_lib:format("erl -detached -sname ~p", [?NODE]),
os:cmd(Cmd).
ping() ->
timer:sleep(3000),
case net_adm:ping(?NODE) of
pong ->
io:format("# Node ~p has been successfully started, I'll stop it for you.~n", [?NODE]),
rpc:call(?NODE, init, stop, []);
pang ->
io:format("# I don't see the node. ~p~n", [?NODE]),
io:format("# But it's still running. You should stop the faulty node by smth like \"killall beam.smp\"~n")
end.
#!/usr/bin/env escript
%% -*- erlang -*-
-define(NODE, test@localhost).
main(_) ->
os:cmd("epmd -daemon"),
net_kernel:start([cli, shortnames]),
start(),
ping().
start() ->
Cmd = io_lib:format("erl -detached -sname ~p", [?NODE]),
os:cmd(Cmd).
ping() ->
timer:sleep(3000),
case net_adm:ping(?NODE) of
pong ->
io:format("# Node ~p has been successfully started, I'll stop it for you.~n", [?NODE]),
rpc:call(?NODE, init, stop, []);
pang ->
io:format("# I don't see the node. ~p~n", [?NODE]),
io:format("# But it's still running. You should stop the faulty node by smth like \"killall beam.smp\"~n")
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment