I am new the Erlang. Currently, we are using ejabberd for our xmpp service. Recently, dues to some capability issue, I have written a distributed erlange program. I need to run rpc:call between two machines. I can do the rpc:call successfully on erl simulator. But our current system was using ejabberdctl to start the ejabberd service. I have check and try to modify the ejabberdctl file. But I can't add -setcookie successfully.
the code section in ejabberdctl is
ctlexec()
{
CONN_NAME=$1; shift
COMMAND=$@
$EXEC_CMD "$ERL \
$NAME ${CONN_NAME} \
-noinput \
-hidden \
-pa $EJABBERD_EBIN_PATH \
$KERNEL_OPTS \
-s ejabberd_ctl -extra $ERLANG_NODE $COMMAND"
}
the problem caused by the last two line:
$KERNEL_OPTS \
-s ejabberd_ctl -extra $ERLANG_NODE $COMMAND"
I think this file is referenced some one's before, but I don't know where are there from. Does anybody know how can I add -setcookie abc to this erl command? If I can't change the ejabberdctl file or the worse case, I can't change the current system. i.e. I don't have a chance to add setcookie to the ejabberd system. How can I connect my new node to the existing ejabberd node(our current system).
The ejabberd suppose to start first.
You have a solution right under your nose. How ctlexec()
works? It runs --hidden
node named $NAME ${CONN_NAME}
, sets options $KERNEL_OPTS
, inserts $EJABBERD_EBIN_PATH
into search path and calls ejabberd_ctl:start()
with some additional parameters in $ERLANG_NODE $COMMAND
. So there must be -setcookie Cookie
parameter in $KERNEL_OPTS
or it uses default cookie in $HOME/.erlang.cookie
. It is exactly what you need. Just replace -s ejabberd_ctl
with your own module and use $KERNEL_OPTS
and $ERLANG_NODE
content which you already have. Search around in the script for clues what $KERNEL_OPTS
and $ERLANG_NODE
contains.
It is a usual way how scripts like ejabberd_ctl
are made. It is pretty simple and elegant. You just run your own node set it --hidden
so you don't disturb other nodes in a cluster if there is such. Don't forget set some random node name. Connect to the application node and then do your rpc:call/4,5
and that's it. There is usually some modules like ejabberd_ctl.erl
to make it more comfortable, process extra parameters and so on.