[erlang-questions] Can't start process when starting erlang node.
yuzhu chen
billcyz@REDACTED
Thu Jun 1 07:54:26 CEST 2017
I was trying to start a supervisor and a gen_server process while one node
is created from the command-line, I use the following command to start the
node:
erl -name vm01@REDACTED -s ets_sup start vm02@REDACTED calc
However, I found the process is undefined when I use whereis to check the
process on the newly created node. I got no problems running ets_sup and
ets_srv on the node shell directly, but starting the node from command line
doesn't work. I want to know why this happening?
ets_sup.erl:
-module(ets_sup).-behaviour(supervisor).-export([start/1,
start_link/1, init/1]).
start([A, B]) ->
start_link([A, B]).
start_link([A, B]) ->
supervisor:start_link({local, ?MODULE}, ?MODULE, [A, B]).
init([A, B]) ->
{ok, {{one_for_all, 0, 1},
[{ets_srv, {ets_srv, start_link, [A, B]}, permanent,
5000, worker, [ets_srv]}]}}.
ets_srv.erl:
-module(ets_srv).-behaviour(gen_server).-compile(export_all).
-record(state, {a, b}).
start_link(A,B) ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [A, B], []).
init([A, B]) ->
{ok, #state{a = A, b = B}}.
check_sys() ->
gen_server:call(?MODULE, check_sys).
handle_call(check_sys, _From, #state{a = A, b = B} = State) ->
{reply, {A, B}, State}.
handle_info(_Info, State) -> {noreply, State}.
handle_cast(_Req, State) -> {noreply, State}.
code_change(_Ol, State, _Ex) -> {ok, State}.
terminate(_R, _S) -> ok.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170601/52fea796/attachment.htm>
More information about the erlang-questions
mailing list