erlang application

3787 단어 application
Erlang application, the first time I came into contact with it at work, the abbreviation is called app. At that time, I was still confused, and it was always wrong with the mobile app. In fact, the erlang app is a collection of modules, and the correlation is strong through the app. The modules are gathered together to facilitate the management and supervision of the specified process. I used to think that the hierarchy of the general erlang project is Nodes -> apps -> super -> process. This is the case. The book also said that the app is used to manage process, but I still feel that super behavior is what really plays a role in management.
The reason why I thought of talking about the app is mainly because there is still a problem about process registration that has not been solved, and I always want to know an exact result!
 
Here, let's assume we're doing a game. Let's take map_app.app as an example to write a configuration file. I really can't remember the parameters here. See other people's comments.
{application, map_app,                                               %%app 
[{description,"the application which createed the processes of map"},%% 
 {vsn,"2.0"},                                                        %% 
 {modules,[]},                                                       %% module, 
 {registered,[]},                                                    %% 
 {maxP,Num},                                                         %% 
 {maxT,Time},                                                        %%app   
 {included_applications,[]}                                          %% app
 {env,[]}                                                            %%app env
 {applications,[kernel,stdlib]},                                     %% application
 {mod,{map_app,[]}}                                                  %%app                                         
 ]
}.
Let's write the code to load the app


-mdoule(map_app).
-behaviour(application).
-export([
	 start/2,
	 stop/1,
	 start/0
        ]).

start()->
	application:start(?MODULE,     permanent).

start(_Type, _StartArgs) ->  
	{ok, _MapSupPid}  = start_map_sup().
    
stop(_State) ->  
    ok.

start_map_sup()->
	case map_sup:start_link() of
		{ok, Pid} ->
			{ok, Pid};
		Error ->
			Error
	end.
 
Here, the loading of the app, the application as a behavioral framework, it will automatically load start/0 and start/2, there is time to see how the source code operates, here we start a super, as a monitoring process, that is, the management Procedure. Used to monitor and manage processes started through it


Write the super code as well
-module(map_sup).

-behaviour(supervisor).
-export([start_link/0, init/1]).

start_link()->
	supervisor:start_link({local,?MODULE}, ?MODULE, []).

init([]) ->
	{ok,{{one_for_one,1000,2}, []}}.
At this point, we have written a small application, and we can start to slowly expand the program after testing.


Recently, I found that although I have done a lot of erlang things in my work, I still have a lot of confusion when I look back. This is good, I can consolidate my foundation and correct my learning methods and attitudes.


I will extend the supervisor stuff to the next program tomorrow.


 



좋은 웹페이지 즐겨찾기