Created
July 15, 2014 18:06
-
-
Save mcqueenorama/34507b5f995ad17469b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I run it like this: | |
ERL_LIBS=deps erl -pa ebin -run jammer | |
which brings me to the prompt where I do jammer:jam(). | |
I want a supervisor of some kind to make sure the thing is always running. | |
I've got a start function which starts everything as a suprvisor would: | |
-module(jammer). | |
. | |
. | |
. | |
start() -> | |
io:format("shell start jammer~n"), | |
application:load(jammer), | |
application:ensure_all_started(jammer), | |
%start the thing indicated in the app src file mod line | |
% application:start(jammer). | |
jammer_sup:start_link(). | |
jam() -> | |
. | |
. | |
. | |
listenLoop(). | |
listenLoop runs forever, its pulling from a queue, using rabbitmq amqp, which is a dependent module and it has its own supervisor from the dependent module's own startup code. | |
My own supervisor starts my own dependent service like this: | |
start_link() -> | |
supervisor:start_link({local, ?SERVER}, ?MODULE, []). | |
init([]) -> | |
Couch_Jammer = {pg_couch, | |
{pg_couch, start_link, []}, | |
permanent,2000,worker, [pg_couch]}, | |
{ok, {{one_for_one, 10, 3600}, [Couch_Jammer]}}. | |
Here's my app.src | |
zup.app.src: | |
{application, jammer, | |
[ | |
{description, ""}, | |
{vsn, "1"}, | |
{registered, []}, | |
{modules, [ | |
jammer | |
]}, | |
{applications, [ | |
kernel, | |
stdlib, | |
couchbeam | |
]}, | |
{mod, { jammer_app, []}} | |
]}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment