ebin
디렉토리에 배치 한 authenticate
모듈에서 setup/0
함수를 호출하는 .yaws 파일이 있습니다. Erlang 쉘에서 authenticate:setup/0
을 호출하면 테이블이 잘 생성되지만, authenticate:setup/0
함수를 호출하는 브라우저에서 something.yaws를로드하면 {aborted,{bad_type,users,disc_copies,[email protected]}}
을 반환합니다 (something.yaws는 html에 authenticate:setup/0
의 반환 값을 반환합니다). 디버깅 목적으로). 여기 Mnesia는 Yaws에 의해 실행될 때 테이블을 만들 수 없지만 Erlang 쉘에서 실행될 수 있습니다.
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}).
(I 그래서, 내가 브라우저에서 그것을 시도 한 후 얼랑 쉘에서 호출 시도 그걸로 간섭하지 못했습니다.)
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]}}
erl -mnesia dir '"/usr/local/lib/yaws-appmods/mnesia/"'
으로 시작되는 Erlang 쉘에서 동일한 erlang 코드를 실행하면 정상적으로 작동합니다.
erl -mnesia dir ' "DIR"''을 사용합니다 (DIR은 두 경우 모두 동일한 디렉토리를 나타냄). yaws의 출력은 코멘트에 맞지 않으므로 필자의 메인 포스트로 편집 할 것입니다. – user1792131