我有调用从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