我有調用從authenticate
模塊我寫的,我已經放在ebin
目錄setup/0
功能的.yaws文件。當我從Erlang shell調用authenticate:setup/0
時,它會創建一個表格,但是當我在瀏覽器中加載了一個叫做authenticate:setup/0
函數的東西時,它會返回{aborted,{bad_type,users,disc_copies,[email protected]}}
(something.yaws只是返回嵌入在html中的返回值authenticate:setup/0
用於調試目的)。的Mnesia不能創建表,但可以從二郎跑時外殼
這裏的setup/0
功能:
setup() ->
mnesia:create_schema([node()]),
mnesia:start(),
mnesia:create_table(users, [{type, set}, {record_name, user}, {disc_copies, [node()]}, {attributes, record_info(fields, user)}]).
和這裏的user
記錄:
-record(user, {username, hashed_pw, salt}).
(我試圖從Erlang shell的調用它,我在瀏覽器中嘗試之後,所以不能干擾它。)
如果我運行yaws --mnesiadir /usr/local/lib/yaws-appmods/mnesia/
,我得到
Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:8:8] [async-threads:10] [kernel-poll:true]
Eshell V8.1 (abort with ^G)
1>
=INFO REPORT==== 7-Nov-2016::00:04:49 ===
Yaws: Using config file /etc/yaws/yaws.conf
=INFO REPORT==== 7-Nov-2016::00:04:49 ===
Yaws: Using global subconfig file /etc/yaws/conf.d/localhost.conf
=INFO REPORT==== 7-Nov-2016::00:04:49 ===
Ctlfile : /home/username/.yaws/yaws/default/CTL
=INFO REPORT==== 7-Nov-2016::00:04:49 ===
Yaws: Listening to 0.0.0.0:8080 for <1> virtual servers:
- http://localhost:8080 under /usr/share/yaws/www
rd(user, {username, hashed_pw, salt}).
user
2> mnesia:create_schema([node()]), mnesia:start(), mnesia:create_table(users, [{type, set}, {record_name, user}, {disc_copies, [node()]}, {attributes, record_info(fields, user)}]).
{aborted,{bad_type,users,disc_copies,[email protected]}}
如果我在Erlang外殼中運行相同的erlang代碼,並以erl -mnesia dir '"/usr/local/lib/yaws-appmods/mnesia/"'
開頭,它就可以工作。
我試過'雅司病--mnesiadir DIR',這還是給了我原來的錯誤,即使它應該有工作的話,我試過' erl -mnesia dir''DIR''',它確實有效(DIR在兩種情況下表示相同的目錄)。雅司的輸出不適合註釋,所以我會將其編輯到我的主帖中。 – user1792131