Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (54 sloc) 2.25 KB

Applications and extensions

Erlang applications

You can use Erlang applications in your Zotonic instance. This is useful when you want to create a Zotonic module that integrates a (third-party) Erlang application into Zotonic. Let’s take mod_elasticsearch, which depends on the erlastic_search library, as an example.

To use Erlang applications in your Zotonic setup, first include them under :ref:`deps` in your zotonic.config file:

Then start the application in your module with application:ensure_all_started:

Configuration for the Erlang application can be added to your :ref:`erlang.config <erlang-config>` file:

Extensions

Zotonic has an extra mechanism for starting additional things that need to be running under the zotonic_sup supervisor. These are called extensions. Extensions are not tied to any particular Zotonic site, but are regular Erlang processes, in OTP fashion.

On the startup of Zotonic, the global $ZOTONIC/priv/extensions folder is scanned once for folders starting with ext_. Each of these folders is considered an extension.

An extension (for instance, ext_foo/ext_foo.erl) can be a regular Erlang module, but is supposed to be something supervisable like a gen_server. It needs to expose at least a function start_link/0. On Zotonic startup, this function is called and the resulting pid is added to the Zotonic supervision tree as a worker process.