ErlyWeb + Yaws 1.64
Some people have had trouble running ErlyWeb on Yaws 1.64. This is because the Yaws ‘arg’ record has changed. I created a Yaws 1.64 compatible yaws_arg.beam file that you can download here. If you’re running Yaws 1.64, drop this file in place of the existing yaws_arg.beam in in your ‘erlyweb-0.x/ebin’ directory, give it another try, and let me know if it helped.
New ErlyWeb Google Group
Following the suggestion of one of my readers, I created a Google group for ErlyWeb hackers. You can join it to ask questions, share points of view, help each other out, make suggestions, and announce the launch of the killer ErlyWeb app you’re building :)
Here’s the link: http://groups.google.com/group/erlyweb
From now on, I will make all announcements about new releases in this group rather than on my blog.
ErlyWeb 0.2
I made some improvements to the first release of ErlyWeb, some based on user feedback, and some based on my own whims :) This is what I did:
- Chaged the LastCompileTime parameter in erlyweb:compile into an option value in the form of {last_compile_time, Time}.
- Added the following options to erlyweb:compile/2:
{auto_compile, true} : this option, useful during development, tells ErlyWeb to compile all files that have changed since the last request when a new request arrives. This frees you from having to call erlyweb:compile every time you make a code change in your app. Just don’t forget to turn auto-compilation off by calling erlyweb:compile without the {auto_compile, true} option when you are switching from development to production mode, because auto-compilation slows things down.
Update (12/6/06): The pre_compile_hook and post_compile_hook have changed in ErlyWeb v0.3. Read this announcement for more details.
{pre_compile_hook, {Module, FuncName}} and {post_compile_hook, {Module, FuncName}}: these option tell ErlyWeb to call the predefined functions before/after (auto)compilation. This allows you to extend the compilation process in an arbitrary way, e.g. by compiling additional files that are outside of the application’s src directory. Both functions take a single parameter which is the time of the last compilation (or ‘undefined’ if the time is not available). For example, let’s say you have the following file called ‘compile_hooks.erl’ in the ’src’ directory:
-module(compile_hooks).
-compile(export_all).
pre_compile(LastCompileTime) ->
io:format("pre-compile (last: ~p) ~n", [LastCompileTime]).
post_compile(LastCompileTime) ->
io:format("post-compile (last: ~p) ~n", [LastCompileTime]).
You could use the new compilation options as follows:
erlyweb:compile("/path/to/app",
[{erlydb_driver, mysql},
{auto_compile, true},
{pre_compile_hook, {compile_hooks, pre_compile}},
{post_compile_hook, {compile_hooks, post_compile}}]).
From now on, every time ErlyWeb does an auto-compilation, it will call those hooks, passing into them the time of the last compilation (or ‘undefined’ on the first compilation).
- Changed the include directive in yaws_arg.erl from ‘-include(”yaws/include/yaws_api.hrl”).’ to ‘-include(”yaws_api.hrl”).’ (this removes assumptions about your Yaws path structure).
- Changed the docroot directive in yaws from pointing at the application’s base directory to [base]/www. E.g., if your previous docroot line was
docroot = /apps/music
it should now be
docroot = /apps/music/www
(there’s no change in behavior — it just makes the configuration more explicit).
That’s it :)
Note: a few people have asked me whether ErlyWeb requires a MySQL database. The answer is ‘no.’ You can use ErlyWeb without any database backend. Just don’t keep the source files for any models in src/components, and then you’ll never even have to call erlydb:start().
In a minute, I’ll put the new zip file on erlyweb.org so you can download it all in one shot.


