Skip to content

Loading…

My solution for issue #75 #76

Closed
wants to merge 1 commit into from

3 participants

@hirschenberger

Adds a new configuration option additional_supervisors with a list of
modules which implement the gen_fsm behaviour. These supervisors will
be started in boss' supervision tree. It can be used to include complex
backend functionality directly in the boss application and start it all
together.

hirschen Add additional applications to boss' applications
Adds a new configuration option `additional_supervisors` with a list of
modules which implement the `gen_fsm` behaviour. These supervisors will
be started in boss' supervision tree. It can be used to include complex
backend functionality directly in the boss application and start it all
together.
2266f98
@evanmiller

Hmm. Why don't you make these sorts of things a separate application and start/stop the application in a CB init script?

@hirschenberger

There's no init script left after rebarizing and I think this functionality belongs into one supervision tree.

@evanmiller

You can put init scripts into priv/init, see the example script in a new project. Can you give me an example where external services should be brought up in CB's supervision tree and not under the root supervisor?

Thinking about it, the way to go might be just adding the application names to your project's 'applications' config parameter, and let OTP take care of the rest (see http://www.erlang.org/doc/design_principles/applications.html).

@hirschenberger

Oh, I wasn't aware that the priv/init stuff can be used for any kind of initialization, I thought it is watchID specific. That could have solved my problem.

I searched for a way to start my backend application along with boss in the same VM and I find it kind of elegant to inject my backend code into Boss with my solution.

I tested the way you mentioned, adding my app to applications but it doesn't work, as there are boss webapps expected and the initialization procedure fails because it doesn't find a route file.

@zkessin

Closing this as no longer of interest

@zkessin zkessin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 17, 2012
  1. Add additional applications to boss' applications

    hirschen committed
    Adds a new configuration option `additional_supervisors` with a list of
    modules which implement the `gen_fsm` behaviour. These supervisors will
    be started in boss' supervision tree. It can be used to include complex
    backend functionality directly in the boss application and start it all
    together.
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 1 deletion.
  1. +1 −0 doc-src/api-config.html
  2. +10 −1 src/boss/boss_sup.erl
View
1 doc-src/api-config.html
@@ -2,6 +2,7 @@
{% block api_content %}
<p>All configuration takes place in <code>boss.config</code> in your project directory. Valid configuration options are:</p>
<ul>
+ <li><code>additional_supervisors</code> - A list of modules which implement the OTP-Supervisor (<code>gen_sup</code>) behaviour. These supervisors will be started in Boss' supervision tree and can be used to implement complex backend behaviour.</li>
<li><code>assume_locale</code> - The presumed locale of translatable strings. Defaults to "en".</li>
<li><code>cache_adapter</code> - The cache adapter to use. Currently the only valid value is <code>memcached_bin</code>.</li>
<li><code>cache_servers</code> - A list of cache servers (<code>{Host, Port, PoolSize}</code>). Defaults to <code>[{"localhost", 11211, 1}]</code>.
View
11 src/boss/boss_sup.erl
@@ -48,5 +48,14 @@ init([]) ->
{boss_web_controller, start_link, [WebConfig]},
permanent, 5000, worker, dynamic},
- Processes = [Web],
+ % add additional supervisors to the supervision tree
+ AddSups = boss_env:get_env(additional_supervisors, []),
+
+ Processes = lists:foldl(fun(App, Acc) ->
+ [{App,
+ {App, start_link, []},
+ permanent, 5000, worker, []}
+ |Acc]
+ end, [Web], AddSups),
+
{ok, {{one_for_one, 10, 10}, Processes}}.
Something went wrong with that request. Please try again.