Skip to content

Commit

Permalink
Preparing for rebar deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Licenser committed May 5, 2012
1 parent 21f36c6 commit 946cda4
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 38 deletions.
17 changes: 12 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# BOF

.svn

# EOF
ebin
db
deps
*~
.DS_Store
Mnesia.*
erl_crash.dump
*.beam
rel/wiggle
rel/wiggle.tar.bz2
manifest
gproc_dist_sniffle*
13 changes: 13 additions & 0 deletions apps/nodefinder/src/nodefinder.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{application, nodefinder,
[
{description, ""},
{vsn, "0.1.0"},
{registered, []},
{applications, [
kernel,
stdlib,
crypto
]},
{mod, { nodefinder_app, []}},
{env, []}
]}.
22 changes: 13 additions & 9 deletions apps/nodefinder/src/nodefinder_app.erl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
%% @doc Nodefinder service.
%% @end

-module (nodefinder).
-export ([ discover/0 ]).
-behaviour (application).
-export ([ start/0, start/2, stop/0, stop/1 ]).
-module(nodefinder_app).
-export([ discover/0 ]).
-behaviour(application).
-export([ start/0, start/2, stop/0, stop/1 ]).

%-=====================================================================-
%- Public -
Expand All @@ -16,7 +16,7 @@
%% @end

discover () ->
nodefindersrv:discover ().
nodefinder_srv:discover ().

%-=====================================================================-
%- application callbacks -
Expand All @@ -31,10 +31,14 @@ start () ->
%% @hidden

start (_Type, _Args) ->
{ ok, Addr } = application:get_env (nodefinder, addr),
{ ok, Port } = application:get_env (nodefinder, port),
{ ok, Ttl } = application:get_env (nodefinder, multicast_ttl),
nodefindersup:start_link (Addr, Port, Ttl).
io:format("1~n"),
{ ok, Addr } = application:get_env (nodefinder, addr),
io:format("2~n"),
{ ok, Port } = application:get_env (nodefinder, port),
io:format("3~n"),
{ ok, Ttl } = application:get_env (nodefinder, multicast_ttl),
io:format("4~n"),
nodefinder_sup:start_link (Addr, Port, Ttl).

%% @hidden

Expand Down
40 changes: 21 additions & 19 deletions apps/nodefinder/src/nodefinder_srv.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%% @hidden
%% @end

-module (nodefindersrv).
-module (nodefinder_srv).
-behaviour (gen_server).
-export ([ start_link/2, start_link/3, discover/0 ]).
-export ([ init/1,
Expand Down Expand Up @@ -37,24 +37,26 @@ discover () ->
%-=====================================================================-

init ([ Addr, Port, Ttl ]) ->
process_flag (trap_exit, true),

Opts = [ { active, true },
{ ip, Addr },
{ add_membership, { Addr, { 0, 0, 0, 0 } } },
{ multicast_loop, true },
{ reuseaddr, true },
list ],

{ ok, RecvSocket } = gen_udp:open (Port, Opts),

{ ok, discover (#statev2{ recvsock = RecvSocket,
sendsock = send_socket (Ttl),
addr = Addr,
port = Port }) }.

handle_call (discover, _From, State) -> { reply, ok, discover (State) };
handle_call (_Request, _From, State) -> { noreply, State }.
io:format("bla~n"),
process_flag (trap_exit, true),
Opts = [{active, true },
{ip, Addr },
{add_membership, {Addr,{0, 0, 0, 0}}},
{multicast_loop, true},
{reuseaddr, true},
list ],
io:format("Opts: ~p~n", [Opts]),
{ ok, RecvSocket } = gen_udp:open(Port, Opts),
io:format("Sock: ~p~n", [RecvSocket]),
{ ok, discover (#statev2{recvsock = RecvSocket,
sendsock = send_socket (Ttl),
addr = Addr,
port = Port})}.

handle_call (discover, _From, State) ->
{reply, ok, discover(State)};
handle_call (_Request, _From, State) ->
{noreply, State}.

handle_cast (_Request, State) -> { noreply, State }.

Expand Down
8 changes: 4 additions & 4 deletions apps/nodefinder/src/nodefinder_sup.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%% @hidden

-module (nodefindersup).
-module (nodefinder_sup).
-behaviour (supervisor).

-export ([ start_link/2, start_link/3, init/1 ]).
Expand All @@ -22,12 +22,12 @@ start_link (Addr, Port, Ttl) ->
init ([ Addr, Port, Ttl ]) ->
{ ok,
{ { one_for_one, 3, 10 },
[ { nodefindersrv,
{ nodefindersrv, start_link, [ Addr, Port, Ttl ] },
[ { nodefinder_srv,
{ nodefinder_srv, start_link, [ Addr, Port, Ttl ] },
permanent,
1000,
worker,
[ nodefindersrv ]
[ nodefinder_srv ]
}
]
}
Expand Down
9 changes: 8 additions & 1 deletion standalone.config
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
[].
[
{nodefinder,
[
{addr, {0,0,0,0}},
{port, 4223},
{multicast_ttl, 1000}
]}
].

0 comments on commit 946cda4

Please sign in to comment.