dimanche 6 novembre 2016

Mnesia can't create tables when ran by Yaws, but can when ran from the Erlang shell

I have a .yaws file which invokes the setup/0 function from the authenticate module I wrote, which I've placed in the ebin directory. When I call authenticate:setup/0 from the Erlang shell, it creates a table just fine, but when I load something.yaws in the browser, which calls the authenticate:setup/0 function, it returns {aborted,{bad_type,users,disc_copies,nonode@nohost}} (something.yaws just returns the return value of authenticate:setup/0 embedded in html for debugging purposes).

Here's the setup/0 function:

setup() ->
    mnesia:create_schema([node()]),
    mnesia:start(),
    mnesia:create_table(users, [{type, set}, {record_name, user}, {disc_copies, [node()]}, {attributes, record_info(fields, user)}]).

and here's the user record:

-record(user, {username, hashed_pw, salt}).

(I have tried calling it from the Erlang shell after I've tried it in the browser, so that couldn't have interfered with it.)




Aucun commentaire:

Enregistrer un commentaire