2016-02-05 51 views
1

我創建了一個Erlang應用程序,一個小的calendar_server。其中插入事件,檢索它們並編輯和刪除事件。它在提示符上運行時使用正確(使用erl)。我插入了事件(生日,會議等),然後在目錄上創建數據庫([email protected])。並有可能檢索事件。但是,當使用rebar/rebar3創建相同的應用程序時,不會創建數據庫。我真的很想知道我面臨的問題,或者我做了什麼錯誤。數據庫不是在發佈Erlang應用程序時創建的

的reltool.config和calendarApp.app.src在下面給出..

reltool.config

{sys, [ 
    {lib_dirs, ["../apps"]}, 
    {erts, [{mod_cond, derived}, {app_file, strip}]}, 
    {app_file, strip}, 
    {rel, "calendarApp", "1", 
    [ 
    kernel, 
    stdlib, 
    sasl, 
    mnesia, 
    calendarApp 
    ]}, 
    {rel, "start_clean", "", 
    [ 
    kernel, 
    stdlib 
    ]}, 
    {boot_rel, "calendarApp"}, 
    {profile, embedded}, 
    {incl_cond, exclude}, 
    {excl_archive_filters, [".*"]}, %% Do not archive built libs 
    {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)", 
         "^erts.*/(doc|info|include|lib|man|src)"]}, 
    {excl_app_filters, ["\.gitignore"]}, 
    {app, sasl, [{incl_cond, include}]}, 
    {app, stdlib, [{incl_cond, include}]}, 
    {app, kernel, [{incl_cond, include}]}, 
    {app, mnesia, [{incl_cond, include}]}, 
    {app, calendarApp, [{incl_cond, include}]} 
    ]}. 

    {target_dir, "calendarApp"}. 

    {overlay, [ 
      {mkdir, "log/sasl"}, 
      {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"}, 
      {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"}, 
      {copy, "files/calendarApp", "bin/calendarApp"}, 
      {copy, "files/calendarApp.cmd", "bin/calendarApp.cmd"}, 
      {copy, "files/start_erl.cmd", "bin/start_erl.cmd"}, 
      {copy, "files/install_upgrade.escript",  "bin/install_upgrade.escript"}, 
      {copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"}, 
      {copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"} 
     ]}. 

calendarApp.app.src

{application, calendarApp, 
[ 
    {description, ""}, 
    {vsn, "1"}, 
    {registered, []}, 
    {applications, [ 
       kernel, 
       stdlib, 
       mnesia 
      ]}, 
    {mod, { calendarApp_app, []}}, 
    {env, []} 
]}. 

如果有人知道爲什麼數據庫沒有創建,請幫我找到我的錯誤。

回答

1

要創建基於光盤的Mnesia,您可以使用mnesia:create_schema/1函數(我認爲您在代碼中執行過某處)。此功能要求Mnesia爲停止

在你的reltool.config你指定mnesia應用程序之前calendarApp應用程序,這是你可能創建基於mnesia光盤的模式。這意味着mnesia在創建模式之前就已經啓動了,所以無法創建模式。

如果你的relreltool.config文件項下改變mnesiacalendarApp秩序,一切都應該是正確的。

{sys, [ 
    {lib_dirs, ["../apps"]}, 
    {erts, [{mod_cond, derived}, {app_file, strip}]}, 
    {app_file, strip}, 
    {rel, "calendarApp", "1", 
    [ 
    kernel, 
    stdlib, 
    sasl, 
    calendarApp, 
    mnesia 
    ]}, 
    ... 
+0

謝謝,讓我試試看,並儘快回覆。再次感謝你 – sonukrishna

相關問題