Automatic code reloading in Erlang
I’ve recently got back to coding Erlang and noticed a neat module that I didn’t know existed that is probably worth writing a blog entry about. I’ve started developing a PubSubHubbub hub in Erlang called Hubbabubba and I’m using the great Mochiweb HTTP library as the HTTP server implementation. I discovered the reloader.erl module that comes with Mochiweb. It automatically reloads the code when you have the application running and you modify the code (remember to compile as well). This is something that I’ve found very useful when developing with Django or AppEngine and I’m really satisfied that there is a similar solution for Erlang as well.
February 16th, 2010 at 7:29 am
Hey, I stumbled upon this reloader module recently in mochiweb. But I wonder if this reloader module will cause any overload on the system. Doesn’t it constantly have to monitor the beam files to check for an updation? Any thoughts?
February 16th, 2010 at 8:25 am
Hey Jason,
Yes, I use it only while developing. It makes it lot easier when after compiling the code it is automatically loaded to the e.g. server I’m developing and runs tests automatically etc. I think in production systems the code upgrades should be done using the features that OTP provides. Using that you can easily fallback to previous version of code if something goes wrong.