Permalink
Browse files

make gen_netlink a proper app

  • Loading branch information...
1 parent 43f3447 commit fd72be0ad283e9b11472871f68d44547334db2bf @RoadRunnr RoadRunnr committed with tpiadmin Jul 25, 2011
Showing with 56 additions and 1 deletion.
  1. +2 −1 ebin/gen_netlink.app
  2. +10 −0 src/gen_netlink.app.src
  3. +16 −0 src/gen_netlink_app.erl
  4. +28 −0 src/gen_netlink_sup.erl
View
@@ -1,8 +1,9 @@
{application, gen_netlink,
[{description,"Netlink socket toolkit"},
{vsn,"0.02"},
- {modules,[gen_socket,netlink]},
+ {modules,[gen_netlink_app,gen_netlink_sup,gen_socket,netlink]},
{registered,[]},
{applications,[kernel,stdlib]},
+ {mod,{gen_netlink_app,[]}},
{env,[]}]
}.
View
@@ -0,0 +1,10 @@
+{application, gen_netlink, [
+ {description, "Netlink socket toolkit"},
+ {vsn, "0.02"},
+ {modules, []},
+ {registered, []},
+ {applications, [kernel, stdlib]},
+ {mod, { gen_netlink_app, []}},
+ {env, []}
+]}.
+
View
@@ -0,0 +1,16 @@
+-module(gen_netlink_app).
+
+-behaviour(application).
+
+%% Application callbacks
+-export([start/2, stop/1]).
+
+%% ===================================================================
+%% Application callbacks
+%% ===================================================================
+
+start(_StartType, _StartArgs) ->
+ gen_netlink_sup:start_link().
+
+stop(_State) ->
+ ok.
View
@@ -0,0 +1,28 @@
+-module(gen_netlink_sup).
+
+-behaviour(supervisor).
+
+%% API
+-export([start_link/0]).
+
+%% Supervisor callbacks
+-export([init/1]).
+
+%% Helper macro for declaring children of supervisor
+-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
+
+%% ===================================================================
+%% API functions
+%% ===================================================================
+
+start_link() ->
+ supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+%% ===================================================================
+%% Supervisor callbacks
+%% ===================================================================
+
+init([]) ->
+ {ok, {{one_for_one, 5, 10}, [
+ ?CHILD(netlink, worker)
+ ]} }.

0 comments on commit fd72be0

Please sign in to comment.