How to start a rebar application twice or more with different names?

274 views Asked by At

I have a rebar application called pingpong. After rebar generate I start the packaged application using ./rel/pingpong/bin/pingpong start. The problem is that the erlang VM always has the name -name [email protected] but what I want is to start the application once with the name [email protected] and then again with the name [email protected].

I know that the name stays in ./rel/pingpong/releases/VSN/vm.config but I don't want to manually edit the file before starting the application. I want something like pingpong start -name=ping. Is there a way to achieve this?

1

There are 1 answers

1
AudioBubble On BEST ANSWER

You can edit the bin/pingpong script to something like thist:

Instead of

NAME_ARG=`egrep -e '^-s?name' $RUNNER_ETC_DIR/vm.args`

set:

NAME_ARG=${NAME_ARG:-`egrep -e '^-s?name' $RUNNER_ETC_DIR/vm.args`}

in this way you will be able to override node name from the command line:

NAME_ARG="-name myname@localhost" bin/pingpong start

For console/start command:

Find a line in yout startup script:

CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH"

Add $NAME_ARG at the end:

 CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH $NAME_ARG"

And don't forget to remove -name NAME from your .args files