Search code examples
erlangejabberdmochiweb

Mochiweb debug (like ejabberd debug)


I was wonderng if anyone knows of a way to get into Mochiweb like ejabberd does when you run /sbin/ejabberdctl debug?


Solution

    1. Make sure that -sname $NODE@$HOST (or -name $NODE@$FULLHOST) is present in parameters of erl call in start.sh of your mochiweb-based project
    2. Create file debug.sh with the following code:

      #!/bin/bash
      erl -sname debug_$NODE@$HOST -remsh $NODE@$HOST
      

    Make sure not to mix sname and name in scripts, because nodes with short names can not communicate with nodes with full names (and vice versa). Additionally make sure to use the same cookie on both nodes either via -setcookie parameter of erl or via ~/.erlang.cookie file.

    Of course you have to replace $NODE, $HOST and $FULLHOST with appropriate values.