Nitrogen module auto-reloading

This is a really simple tip, but it was handy for me, and it could be helpful for someone else, too.

While playing around with Nitrogen, which is a great project by the way (more in a later blog post, I guarantee it), I noticed that I had to restart the server to re-load modules as I changed them (or I could manually, reload them, I know, I know..).

Since I was using Mochiweb as my backend, and I’m used to the development version of Mochiweb auto-reloading modules as you recompile, I wanted the same functionality here.

Turns out it’s as simple as changing the default start.sh from

    #!/bin/sh
    cd `dirname $0`
    
    echo Starting Nitrogen.
    erl \
    	-name nitrogen@localhost \
    	-pa ./ebin -pa ./include \
    	-s make all \
    	-eval "application:start(appname)"

to this

    #!/bin/sh
    cd `dirname $0`
    
    echo Starting Nitrogen.
    erl \
    	-name nitrogen@localhost \
    	-pa ./ebin -pa ./include \
    	-s make all \
    	-s reloader \
    	-eval "application:start(appname)"

… and bam, modules now reload as you recompile them.

blog comments powered by Disqus