Re: difficulty getting mnesia to work with cowboy web backend

Eric PAILLEAU <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <[email protected]>
Hi,
you are confusing external dependancies and code dependancies.

DEPS variable in Erlang.mk is to download locally external projects your
project is depending.

You have to add in your .app  (or legacy .app.src) the list of
applications your own application is depending.

mnesia is internal to OTP, it comes with the release, there is no need
to declare it as external dependancy.

For instance a zotonic_mod_ratelimit.app.src file

{application, zotonic_mod_ratelimit, [
    {description, "Rate limiting of authentication tries and other types
of requests."},
    {vsn, {file, "../../VERSION"}},
    {registered, []},
    {applications, [kernel, stdlib, *mnesia*, zotonic_core]},
    {env, []},
    {modules, []},
    {maintainers, []},
    {licenses, ["Apache 2.0"]},
    {links, [{"GitHub", "https://github.com/zotonic/zotonic"}]}
]}.


Regards


Le 25/10/2020 à 00:31, jdmeta a écrit :
> 
> i'm building a web backend using cowboy and mnesia.
> at this point i'm running mnesia on only one node and don't need
> distributed mnesia for the foreseeable future.
> 
> i installed cowboy and bootstrapped my cowboy app per the instructions
> in the cowboy user guide on ninenines.eu.
> i run my cowboy app with "make run" which uses the rather involved
> "erlang.mk" makefile in the ninenines repo.
> 
> i need to specify that my cowboy app is dependent on the mnesia app.
> i edited "Makefile" in my app's root directory and added "mnesia" to the
> DEPS variable.
> when i then execute "make run" i get "Error: Unknown or invalid
> dependency: mnesia."
> 
> when i execute "make run", erlang.mk appears to automatically construct
> ebin/<my_app>.app - no doubt using some other input which i haven't
> found yet.
> if i manually edit ebin/<my_app>.app to add mnesia to the "applications"
> tuple then mnesia runs as expected.
> 
> how do i specify that my cowboy app is dependent on mnesia such that the
> <my_app>.app config file gets constructed correctly every time i execute
> "make run"?
> 
> but wait, there's more... :(
> 
> i constructed an mnesia schema in a particular directory under the
> cowboy app directory hierarchy.
> i need to specify this directory to mnesia which apparently can only be
> done using the "-mnesia dir <Dir>" option to erl.
> 
> is there any other way to do this?
> why isn't the schema directory an argument to mnesia:start()?
> that seems much more intuitive.
> 
> back again to the gigantic erlang.mk where i found where the erl command
> that runs erts which in turn runs my cowboy app.
> i added the "-mnesia dir <Dir>" option to the erl command line, but
> mnesia is still not finding my pre-defined schema - it's running in
> ram-only mode which means it didn't find a pre-defined schema.
> 
> i can run erl manually in the directory above the directory where my
> pre-defined schema is located, and see that the schema is there and it's
> configured as i expected.
> 
> when executing "make run" (navigating through the erlang.mk maze), how
> do i get mnesia to see the schema directory when it's launched by the
> cowboy app?
> do i need to pass an argument to some start() function?
> does erlang.mk need to be modified or one of its inputs modified?
> 
> thanx for any assistance!
>
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEE/BqEhJJ84aukOqYB5djqWdYlW+IFAl+VPQkACgkQ5djqWdYl
W+KlTgf8CmfyHtesM7rMsDlGA/WUiC78f1Wr0sHKXdBxniuMQOmG0bjsjXTZqCXI
QA2Q8CCwz9Itu4VFtHheJ0N+Sf8+4J0ueD33iJRWYXp/JBBUCTfHIVssehALTLmU
lJ7PKyPjCk1XpQ3gh6KWamJpXgi0nX/GdhQLHP6g+7KxTnG0JuDcXMdUg78CmwNH
TCsJe2/c5JuDFQGLaJ+NxbwCxvZf38hDSAPr3Q98Les/F2qlLb0SLyfjwzDK/n3b
HSz+mVKSFUzlz7NPiqB1mp7YbOWuQGVvWLVdwCMOzb2QagDEQPRG2TsrKP+hTPuR
yuzOa1tUChMAO6EisKC0nnXjTiBdyw==
=tIJW
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.