Chinaunix首页 | 论坛 | 博客
  • 博客访问: 49769
  • 博文数量: 9
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 92
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-27 19:21
文章分类

全部博文(9)

文章存档

2014年(9)

我的朋友

分类: Erlang

2014-09-11 15:28:24

首先找到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 <- boss_files:model_list (?APPNAME) ],
  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

阅读(2019) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~