Skip to content
Browse files

Simplfied the app so it's just a single supervisor starting point.

  • Loading branch information...
1 parent 4262739 commit 75b14d49b4b0eacc1fc4df81ebd7313c396db9ee @dustin committed Jun 3, 2008
View
6 .gitignore
@@ -1,6 +1,6 @@
ebin
-lock_serv.boot
-lock_serv.script
-lock_serv.log
+lock_supervisor.boot
+lock_supervisor.script
+lock_supervisor.log
erl_crash.dump
cov.html
View
11 Makefile
@@ -4,7 +4,7 @@ EFLAGS=-pa ebin
.PHONY: tgz
-all: lock_serv.boot
+all: lock_supervisor.boot
tgz: lock_serv.tar.gz
@@ -17,13 +17,14 @@ ebins:
erl $(EFLAGS) -make
cp src/*.app ebin
-lock_serv.boot: ebins lock_serv.rel
- erlc -W -v $(EFLAGS) lock_serv.rel
+lock_supervisor.boot: ebins lock_supervisor.rel
+ erlc -W -v $(EFLAGS) lock_supervisor.rel
lock_serv.tar.gz: lock_serv.boot
- erl $(EFLAGS) -noshell -run systools make_tar lock_serv -run init stop
+ erl $(EFLAGS) -noshell -run systools make_tar lock_supervisor -run init stop
clean:
- rm -f lock_serv.beam lock_serv.boot lock_serv.script lock_serv.tar.gz
+ rm -f lock_supervisor.beam lock_supervisor.boot lock_supervisor.script
+ rm -f lock_supervisor.tar.gz
rm -f cov.html erl_crash.dump
rm -rf ebin
View
3 lock_serv.rel → lock_supervisor.rel
@@ -8,7 +8,6 @@
{"lock_serv_rel", "1.0"},
{erts, "5.3"},
[ {kernel, "2.12.2"}, {stdlib, "1.15.2"},
- {lock_tcp_listener, "1.0"},
- {lock_serv, "1.0"}
+ {lock_supervisor, "1.0"}
]
}.
View
12 src/gen_sup.erl
@@ -0,0 +1,12 @@
+%%
+%% A really generic supervisor.
+%%
+
+-module(gen_sup).
+
+-behavior(supervisor).
+
+-export([init/1]).
+
+% Generic supervisor initialization
+init([Rv|_Args]) -> {ok, Rv}.
View
8 src/lock_serv.app
@@ -1,8 +0,0 @@
-{application, lock_serv,
- [{description, "The lock server."},
- {vsn, "1.0"},
- {modules, [lock_serv]},
- {registered, []},
- {applications, [kernel,stdlib]},
- {mod, {lock_serv_app, []}}
- ]}.
View
35 src/lock_serv_app.erl
@@ -1,35 +0,0 @@
--module (lock_serv_app).
-
--behaviour (application).
-
-% Supervisor functions.
--export([start/0,
- start/2, stop/1, config_change/3, start_phase/3, prep_stop/1]).
-
-% easy start
-start() ->
- application:start(lock_serv).
-
-% application stuff
-start(_Type, _Args) ->
- error_logger:info_msg("Starting lock_serv~n", []),
- lock_serv:start_link().
-
-stop(LockPid) ->
- error_logger:info_msg("Stopping lock_serv~n", []),
- LockPid ! stop,
- ok.
-
-config_change(Changed, New, Removed) ->
- error_logger:info_msg("Config changed: [~p, ~p, ~p]",
- [Changed, New, Removed]),
- ok.
-
-start_phase(Phase, StartType, PhaseArgs) ->
- error_logger:info_msg("start_phase: [~p, ~p, ~p]",
- [Phase, StartType, PhaseArgs]),
- ok.
-
-prep_stop(State) ->
- error_logger:info_msg("Prepping stop of lock_serv~n", []),
- State.
View
9 src/lock_supervisor.app
@@ -0,0 +1,9 @@
+{application, lock_supervisor,
+ [{description, "The lock server."},
+ {vsn, "1.0"},
+ {modules, [lock_supervisor_app, lock_serv,
+ lock_tcp_listener, lock_connection]},
+ {registered, [lock_serv]},
+ {applications, [kernel,stdlib]},
+ {mod, {lock_supervisor_app, []}}
+ ]}.
View
41 src/lock_supervisor_app.erl
@@ -0,0 +1,41 @@
+-module(lock_supervisor_app).
+
+-behaviour (application).
+
+% Supervisor functions.
+-export([start/0,
+ start/2, stop/1, config_change/3, start_phase/3, prep_stop/1]).
+
+% easy start
+start() ->
+ application:start(lock_supervisor).
+
+% application stuff
+start(_Type, _Args) ->
+ error_logger:info_msg("Starting lock_supervisor~n", []),
+ supervisor:start_link(gen_sup, [
+ {{rest_for_one, 2, 60},
+ [{lock_serv, {lock_serv, start_link, []},
+ permanent, 5000, worker, [lock_serv]},
+ {lock_tcp_listener, {lock_tcp_listener, start_link, []},
+ permanent, 5000, worker, [lock_tcp_listener]}
+ ]}]).
+
+stop(LockPid) ->
+ error_logger:info_msg("Stopping lock_supervisor~n", []),
+ LockPid ! stop,
+ ok.
+
+config_change(Changed, New, Removed) ->
+ error_logger:info_msg("Config changed: [~p, ~p, ~p]",
+ [Changed, New, Removed]),
+ ok.
+
+start_phase(Phase, StartType, PhaseArgs) ->
+ error_logger:info_msg("start_phase: [~p, ~p, ~p]",
+ [Phase, StartType, PhaseArgs]),
+ ok.
+
+prep_stop(State) ->
+ error_logger:info_msg("Prepping stop of lock_supervisor~n", []),
+ State.
View
8 src/lock_tcp_listener.app
@@ -1,8 +0,0 @@
-{application, lock_tcp_listener,
- [{description, "TCP listener for a distributed lock server."},
- {vsn, "1.0"},
- {modules, [lock_tcp_listener, lock_connection]},
- {registered, []},
- {applications, [kernel,stdlib]},
- {mod, {lock_tcp_listener_app, []}}
- ]}.
View
35 src/lock_tcp_listener_app.erl
@@ -1,35 +0,0 @@
--module (lock_tcp_listener_app).
-
--behaviour (application).
-
-% Supervisor functions.
--export([start/0,
- start/2, stop/1, config_change/3, start_phase/3, prep_stop/1]).
-
-% easy start
-start() ->
- application:start(lock_tcp_listener).
-
-% application stuff
-start(_Type, _Args) ->
- error_logger:info_msg("Starting lock_tcp_listener", []),
- lock_tcp_listener:start_link().
-
-stop(LockPid) ->
- error_logger:info_msg("Stopping lock_tcp_listener~n", []),
- LockPid ! stop,
- ok.
-
-config_change(Changed, New, Removed) ->
- error_logger:info_msg("Config changed: [~p, ~p, ~p]",
- [Changed, New, Removed]),
- ok.
-
-start_phase(Phase, StartType, PhaseArgs) ->
- error_logger:info_msg("start_phase: [~p, ~p, ~p]",
- [Phase, StartType, PhaseArgs]),
- ok.
-
-prep_stop(State) ->
- error_logger:info_msg("Prepping stop of lock_tcp_listener~n", []),
- State.
View
2 start_lock_serv
@@ -4,4 +4,4 @@
# ./start_lock_serv -noinput -boot environ
# interactive
-erl "$@" -mnesia dir "\"$HOME/tmp/mnesia\"" -pa ebin -boot lock_serv
+erl "$@" -mnesia dir "\"$HOME/tmp/mnesia\"" -pa ebin -boot lock_supervisor

0 comments on commit 75b14d4

Please sign in to comment.
Something went wrong with that request. Please try again.