我有一个.yaws文件,它调用我写setup/0的authenticate模块中的函数,我把它放在ebin目录中.当我authenticate:setup/0从Erlang shell 调用时,它创建一个表就好了,但是当我在浏览器中加载something.yaws时,调用该authenticate:setup/0函数,它返回{aborted,{bad_type,users,disc_copies,nonode@nohost}}(something.yaws只返回authenticate:setup/0嵌入在html中的返回值以进行调试) .
这是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)}]).
Run Code Online (Sandbox Code Playgroud)
这是user记录:
-record(user, {username, hashed_pw, salt}).
Run Code Online (Sandbox Code Playgroud)
(我已经尝试在浏览器中尝试之后从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 …Run Code Online (Sandbox Code Playgroud)