Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[938994]: src / erl / mhive.erl Maximize Restore History

Download this file

mhive.erl    54 lines (47 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-module(mhive).
-behaviour(application).
-export([start/2, stop/1, startapp/0, stopapp/0, configure/0]).
-include("schema.hrl").
startapp()->
Node=libnet:local_name(),
Self=libnet:local_name("starter"),
net_kernel:start([Self]),
S=rpc:call(Node,application,start,[sasl]),
io:format("Startup ~p",[S]),
M=rpc:call(Node,application,start,[mhive]),
io:format("Startup ~p",[M]),
init:stop().
stopapp()->
Node=libnet:local_name(),
Self=libnet:local_name("stopper"),
io:format("Using Local Name ~p~n",[Node]),
net_kernel:start([Self]),
R=rpc:call(Node,init,stop,[]),
io:format("Shutdown ~p",[R]),
init:stop().
configure()->
setup:setup().
% init:stop().
start(_Type, StartArgs)->
Node=libnet:local_name(),
io:format("Self node = ~p",[Node]),
net_kernel:start([Node]),
net_adm:world(),
mnesia:start(),
mnesia:wait_for_tables([config],5000),
application:set_env(mhive,port,config:get(http_port,8080)),
application:set_env(mhive,wwwroot,filename:join(libcode:get_privdir(),"wwwroot")),
case config:get(mode) of
server->
mhive_supervisor:start_link(StartArgs);
client->
client_supervisor:start_link(StartArgs);
both->
mhive_supervisor:start_link(StartArgs),
client_supervisor:start_link(StartArgs);
_->system_not_configured
end.
stop(_State)->
% nitrogen:stop(),
% net_kernel:stop(),
ok.