首先找到boss.config,更改数据库和session的配置(我这里数据库选择mnesia,session选择mock内存),如下:
% {db_host, "localhost"},
% {db_port, 1978},
% {db_adapter, mock},
{db_adapter, mnesia},
% {db_username, "boss"},
% {db_password, "boss"},
% {db_database, "boss"},
默认是mock的
% {session_adapter, mnesia},
{session_adapter, mock},
{session_key, "_boss_session"},
session本来默认是mock的,但当数据库改为mnesia的时候,session也改成mnesia了,要再改回来
现在还不能启动,在命令行下进入wmadmin的根目录,执行erl -sname wmadmin,进入终端后执行mnesia:create_schema([node()]). 执行完成后退出。在priv/init/目录下新建my_wmadmin_util.erl文件,内容如下:
-module (my_wmadmin_util).
-compile (export_all).
-define (APPNAME, wmadmin). % is it possible to get it automatically somewhere in CB?
init() ->
init_db (),
ok.
init_db () ->
init_db ([node ()]). % only for local node? what about nodes()++[node()]?
init_db (Nodes) ->
mnesia:create_schema (Nodes),
mnesia:change_table_copy_type (schema, node(), disc_copies), % only for local node?
mnesia:start (),
ModelList = [ list_to_atom (M) || M ExistingTables = mnesia:system_info(tables),
Tables = (ModelList ++ ['_ids_']) -- ExistingTables,
create_model_tables (Nodes, Tables).
% create all the tables
create_model_tables (_, []) -> ok;
create_model_tables (Nodes, [Model | Models]) ->
[create_model_table (Nodes, Model)] ++
create_model_tables (Nodes, Models).
% specific tables (not generated from model)
create_model_table (Nodes, '_ids_') ->
create_table (Nodes, '_ids_', [type, id]);
% tables generated from model
create_model_table (Nodes, Model) ->
Record = boss_record_lib:dummy_record (Model),
{ Model, create_table (Nodes, Model, Record:attribute_names ()) }.
% single table creator wrapper
create_table (Nodes, Table, Attribs) ->
mnesia:create_table (Table,
[ { disc_copies, Nodes },
{ attributes, Attribs } ]).
现在就可以正常启动了,,start-server.bat