diff --git a/apps/iot/src/iot_app.erl b/apps/iot/src/iot_app.erl index edafae9..8402d47 100644 --- a/apps/iot/src/iot_app.erl +++ b/apps/iot/src/iot_app.erl @@ -17,7 +17,7 @@ start(_StartType, _StartArgs) -> erlang:system_flag(fullsweep_after, 16), %% 启动数据库 - start_mnesia(), + % start_mnesia(), {ok, SupPid} = iot_sup:start_link(), %% 启动udp服务 @@ -69,31 +69,31 @@ start_udp_server() -> lager:debug("[iot_app] the udp server start at: ~p", [Port]). %% 启动内存数据库 -start_mnesia() -> - %% 启动数据库 - ok = mnesia:start(), - Tables = mnesia:system_info(tables), - - LoadTables = [totalizator], - case lists:all(fun(Tab) -> lists:member(Tab, Tables) end, LoadTables) of - true -> - lager:debug("[iot_app] waiting for mnesia start: ~p", [LoadTables]), - %% 加载必须等待的数据库表 - mnesia:wait_for_tables(LoadTables, infinity), - lager:debug("[iot_app] waiting for mnesia end"); - false -> - lager:warning("[iot_app] tables: ~p not exists, recreate mnesia schema", [LoadTables]), - %% 清理掉以前的schema - mnesia:stop(), - mnesia:delete_schema([node()]), - - %% 创建schema - ok = mnesia:create_schema([node()]), - ok = mnesia:start(), - - %% 创建数据库表 - %% id生成器 - %% mnesia_id_generator:create_table(), - %% 大数据统计表 - mnesia_totalizator:create_table() - end. \ No newline at end of file +%start_mnesia() -> +% %% 启动数据库 +% ok = mnesia:start(), +% Tables = mnesia:system_info(tables), +% +% LoadTables = [totalizator], +% case lists:all(fun(Tab) -> lists:member(Tab, Tables) end, LoadTables) of +% true -> +% lager:debug("[iot_app] waiting for mnesia start: ~p", [LoadTables]), +% %% 加载必须等待的数据库表 +% mnesia:wait_for_tables(LoadTables, infinity), +% lager:debug("[iot_app] waiting for mnesia end"); +% false -> +% lager:warning("[iot_app] tables: ~p not exists, recreate mnesia schema", [LoadTables]), +% %% 清理掉以前的schema +% mnesia:stop(), +% mnesia:delete_schema([node()]), +% +% %% 创建schema +% ok = mnesia:create_schema([node()]), +% ok = mnesia:start(), +% +% %% 创建数据库表 +% %% id生成器 +% %% mnesia_id_generator:create_table(), +% %% 大数据统计表 +% mnesia_totalizator:create_table() +% end. \ No newline at end of file