Directory Structure
Overview
Erlang Web framework is built upon OTP principles, which implies some conventions on it. One of them is directory structure. Project must contain at least the following set of directories:
- config
- docroot
- lib
- log
- pipes
- priv
- releases
- templates
Directory Meaning
config
config directory is the place where all configuration files should be placed. The must-have files are:
- dispatch.conf - routing rules for dispatcher
- errors.conf - error templates definition
- project.conf - main configuration file for the whole project
- configuration file for server - server-specific configuration file (for Inets - inets.conf, for Yaws - yaws.conf). Moreover, we should place server certificates and keys files here (for example in config/keys).
docroot
docroot directory is a folder for content, which should be served directly by server (without processing by our application), like CSS files, images, binary files, etc. To access it directly, we should place a static route rule in dispatch.conf file (or one of the included ones) with target set to enoent.
lib
lib directory is the place where applications created by users should be placed. Directories lib/*/ebin are automatically added to virtual machine path. After the installation, it should contain either symbolic links or copies of all used Erlang application, i.e. stdlib, kernel, mnesia, compiler, eptic, wpart, wparts, runtime tools and yaws or inets. Each directory inside lib must satisfy OTP directory structure principles (contains at least folders: src for Erlang source code, ebin for Erlang object code and .app file, priv for application specific files and include for include files).
log
log directory is a container for logs created during running in embedded mode. Moreover, web servers default configuration file (inets.conf or yaws.conf) points this folder as a directory for its logs.
pipes
pipes directory holds the OS-level pipes for communicating with the shell of Erlang embedded system.
priv
priv directory is a place for all project specific data: for example static html content (e.g. in priv/static).
releases
releases directory contains separate subdirectories for each release version. Version folders should contain .rel file, boot script start.boot and optionally relup file. In the releases directory we have to put sys.config as well.
templates
templates folder is a place for all template files used within the project. By default cache files are kept in templates/cache folder.
Example of a directory tree
.
|..config
|----dispatch.conf
|----errors.conf
|----project.conf
|----yaws.conf
|..docroot
|..lib
|----eptic
.....|----ebin
.....|----include
.....|----priv
.....|----src
%%...
|----myapp
.....|----ebin
.....|----include
.....|----priv
.....|----src
|----runtime_tools
.....|----ebin
.....|----include
.....|----priv
.....|----src
|----second_app
.....|----ebin
.....|----include
.....|----priv
.....|----src
|..log
|..pipes
|..priv
|..releases
|----sys.config
|..templates