diff options
author | Mickaël Rémond <mremond@process-one.net> | 2015-01-29 18:43:47 +0100 |
---|---|---|
committer | Mickaël Rémond <mremond@process-one.net> | 2015-02-10 17:56:44 +0100 |
commit | 01e1f677c72b923251f7021bc024319ff129d42d (patch) | |
tree | 38c3101d86f42b62774df909193cdfe6be69614c /ejabberdctl.template | |
parent | Document EJABBERD_CONFIG_PATH in ejabberdctl.cfg (diff) |
Add Elixir support to ejabberd
Diffstat (limited to 'ejabberdctl.template')
-rwxr-xr-x | ejabberdctl.template | 105 |
1 files changed, 75 insertions, 30 deletions
diff --git a/ejabberdctl.template b/ejabberdctl.template index 4e8234c9..2025fd22 100755 --- a/ejabberdctl.template +++ b/ejabberdctl.template @@ -12,6 +12,7 @@ ERLANG_NODE=ejabberd@localhost # define default environment variables SCRIPT_DIR=`cd ${0%/*} && pwd` ERL={{erl}} +IEX={{bindir}}/iex INSTALLUSER={{installuser}} # Compatibility in ZSH @@ -128,6 +129,7 @@ if [ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] ; then else NAME="-name" fi +IEXNAME="-$NAME" # define ejabberd environment parameters if [ "$EJABBERD_CONFIG_PATH" != "${EJABBERD_CONFIG_PATH%.yml}" ] ; then @@ -183,6 +185,67 @@ start() # attach to server debug() { + debugwarning + TTY=`tty | sed -e 's/.*\///g'` + $EXEC_CMD "$ERL \ + $NAME debug-${TTY}-${ERLANG_NODE} \ + -remsh $ERLANG_NODE \ + -hidden \ + $KERNEL_OPTS \ + $ERLANG_OPTS $ARGS \"$@\"" +} + +# attach to server using Elixir +iexdebug() +{ + debugwarning + TTY=`tty | sed -e 's/.*\///g'` + # Elixir shell is hidden as default + $EXEC_CMD "$IEX \ + $IEXNAME debug-${TTY}-${ERLANG_NODE} \ + --remsh $ERLANG_NODE \ + --erl \"$KERNEL_OPTS\" \ + --erl \"$ERLANG_OPTS\" --erl \"$ARGS\" --erl \"$@\"" +} + +# start interactive server +live() +{ + livewarning + $EXEC_CMD "$ERL \ + $NAME $ERLANG_NODE \ + -pa $EJABBERD_EBIN_PATH \ + -mnesia dir \"\\\"$SPOOL_DIR\\\"\" \ + $KERNEL_OPTS \ + $EJABBERD_OPTS \ + -s ejabberd \ + $ERLANG_OPTS $ARGS \"$@\"" +} + +# start interactive server with Elixir +iexlive() +{ + livewarning + $EXEC_CMD "$IEX \ + $IEXNAME $ERLANG_NODE \ + -pa $EJABBERD_EBIN_PATH \ + --erl \"-mnesia dir \\\"$SPOOL_DIR\\\"\" \ + --erl \"$KERNEL_OPTS\" \ + --erl \"$EJABBERD_OPTS\" \ + --app ejabberd \ + --erl \"$ERLANG_OPTS\" --erl $ARGS --erl \"$@\"" +} + +etop() +{ + $EXEC_CMD "$ERL \ + $NAME debug-${TTY}-${ERLANG_NODE} \ + -hidden -s etop -s erlang halt -output text -node $ERLANG_NODE" +} + +# TODO: refactor debug warning and livewarning +debugwarning() +{ if [ "$EJABBERD_BYPASS_WARNINGS" != "true" ] ; then echo "--------------------------------------------------------------------" echo "" @@ -199,21 +262,13 @@ debug() echo "--------------------------------------------------------------------" echo "To bypass permanently this warning, add to ejabberdctl.cfg the line:" echo " EJABBERD_BYPASS_WARNINGS=true" - echo "Press any key to continue" + echo "Press return to continue" read foo echo "" - fi - TTY=`tty | sed -e 's/.*\///g'` - $EXEC_CMD "$ERL \ - $NAME debug-${TTY}-${ERLANG_NODE} \ - -remsh $ERLANG_NODE \ - -hidden \ - $KERNEL_OPTS \ - $ERLANG_OPTS $ARGS \"$@\"" + fi } -# start interactive server -live() +livewarning() { check_start if [ "$EJABBERD_BYPASS_WARNINGS" != "true" ] ; then @@ -231,34 +286,22 @@ live() echo "--------------------------------------------------------------------" echo "To bypass permanently this warning, add to ejabberdctl.cfg the line:" echo " EJABBERD_BYPASS_WARNINGS=true" - echo "Press any key to continue" + echo "Press return to continue" read foo echo "" fi - $EXEC_CMD "$ERL \ - $NAME $ERLANG_NODE \ - -pa $EJABBERD_EBIN_PATH \ - -mnesia dir \"\\\"$SPOOL_DIR\\\"\" \ - $KERNEL_OPTS \ - $EJABBERD_OPTS \ - -s ejabberd \ - $ERLANG_OPTS $ARGS \"$@\"" -} - -etop() -{ - $EXEC_CMD "$ERL \ - $NAME debug-${TTY}-${ERLANG_NODE} \ - -hidden -s etop -s erlang halt -output text -node $ERLANG_NODE" } +# TODO: Make iex command display only if ejabberd Elixir support has been enabled help() { echo "" echo "Commands to start an ejabberd node:" - echo " start Start an ejabberd node in server mode" - echo " debug Attach an interactive Erlang shell to a running ejabberd node" - echo " live Start an ejabberd node in live (interactive) mode" + echo " start Start an ejabberd node in server mode" + echo " debug Attach an interactive Erlang shell to a running ejabberd node" + echo " iexdebug Attach an interactive Elixir shell to a running ejabberd node" + echo " live Start an ejabberd node in live (interactive) mode" + echo " iexlive Start an ejabberd node in live (interactive) mode, within an Elixir shell" echo "" echo "Optional parameters when starting an ejabberd node:" echo " --config-dir dir Config ejabberd: $ETC_DIR" @@ -409,7 +452,9 @@ wait_for_status() case $ARGS in ' start') start;; ' debug') debug;; + ' iexdebug') iexdebug;; ' live') live;; + ' iexlive') iexlive;; ' etop') etop;; ' started') wait_for_status 0 30 2;; # wait 30x2s before timeout ' stopped') wait_for_status 3 15 2 && stop_epmd;; # wait 15x2s before timeout |