小编use*_*131的帖子

Mnesia在由Yaws运行时无法创建表,但是可以在从Erlang shell运行时创建

我有一个.yaws文件,它调用我写setup/0authenticate模块中的函数,我把它放在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)

erlang yaws mnesia erlang-shell web

2
推荐指数
1
解决办法
149
查看次数

标签 统计

erlang ×1

erlang-shell ×1

mnesia ×1

web ×1

yaws ×1