1、定义application回调模块
%% 文件名为bank_app.erl -module(bank_app). %% 指定behaviour为application -behaviour(application). %% 导出application回调模块的函数 -export([start/2, stop/1]). %% 启动application时调用 start(_Type, _Args) -> ("Start ~p ...", [?MODULE]), {ok, self()}. %% 停止application时调用 stop(_State) -> ?I("Stop ~p!", [?MODULE]), ok.
2、加载application
application:load({application, bank, [{mod, {bank_app, []}}]}).
application:load/1的参数为application的资源描述,
{application, bank, [{mod, {bank_app, []}}]}中,
指明application的名称为bank,回调模块为bank_app
application的资源描述具体定义可以参见文档:
http://www.erlang.org/doc/man/app.html
3、启动application
application:start(bank).
4、停止application
application:stop(bank).
5、卸载application
application:unload(bank).
时间: 2024-10-12 17:06:16