Skip to content

2 Getting yapps (0.4.0) to work!

humasect edited this page Sep 12, 2010 · 18 revisions

yapps are not packaged with a normal Yaws installation so you have to get the source and build them yourself.
– I had to fix some include paths to get it off the ground, but nothing fancy (I’m using cygwin on windows).

According to the documentation ( the first thing we have to do is create
a proper configuration file. This is how mine turned out:

logdir = C:/yaws/log
include_dir = C:/yaws/include

ebin_dir = ebin
runmod = yapp

port = 8000 listen = docroot = c:/yaws/www arg_rewrite_mod = yapp yapp_server_id = edo port = 8001 listen = docroot = c:/yaws/www arg_rewrite_mod = yapp yapp_server_id = ido bootstrap_yapps = yapp

I have it located in my yapp application directory (“C:\yaws\apps\yapp”).
Here I also created a start script (a batch in my environment) with the following content:
cmd /c “C:\\Progra~1\\erl5.6.4\\lib\\yaws-1.77\\yaws.bat -i -c yapp.conf”

It should be a matter of firing this up but nop, this was a Murphy sponsored installation.

=INFO REPORT== 4-Dec-2008::19:23:25 =
Yaws: Listening to for servers
– http://myinternalserver:8001 under c:/yaws/www
=INFO REPORT== 4-Dec-2008::19:23:25 =
Yaws: Listening to for servers
– http://myexternalserver:8000 under c:/yaws/www
=INFO REPORT== 4-Dec-2008::19:23:25 =
sync call yapp:start
=INFO REPORT== 4-Dec-2008::19:23:25 =
Starting yapp
=INFO REPORT== 4-Dec-2008::19:23:26 =
application: yapp
exited: {shutdown,{yapp_app,start,[normal,[]]}}
type: temporary

I’m not that knowledgeable about OTP applications but I’m quite certain that this shutdown shouldn’t have happened.
I looked up the yapp.erl code and found out that the problem was related with the creation of the necessary y_registry table on mnesia.
Ah! I did do the “mnesia:create_schema([node()]).” step. :P

Adding a “-compile(export_all).” should help at this point.
2> yapp_mnesia_server:init([]).

  • exception error: no match of right hand side value {aborted,
    in function yapp_mnesia_server:init_yapp_reg/0
    in call from yapp_mnesia_server:init/1

Ok, I’m not that much into mnesia either (yet) but a look through the docs got me to try this:
3> mnesia:transaction(fun() → mnesia:read(y_registry, yapp_reg, read) end).

Ok… no table for you! So lets test the “adapted” table creation code:
4> mnesia:create_table(y_registry,[{attributes, [key,value]}, {type,set},{disc_copies, [node()]}]).

Ok… bad_type. What’s that all about? According to the docs: “Bad type on some arguments.”
I bet someone had this same problem at least once and wasn’t afraid to ask for help. Google power!

  1. Erlang questions mailing list ~ aborted, bad_type when creating Mnesia disc only table
  2. Hi,
  3. I succeed to reproduce your problem.
  4. You might have a problem with your schema.
  5. As you want to create a disc_only_copies you have to tell mnesia where
  6. to store table on disc.
  7. Basically, this is done with:
  8. - a mnesia environement variable: mnesia dir. It’s the location of your
  9. tables on disk.
  10. - the schema creation: mnesia:create_schema/1.
  11. Here are the command to create your table
  12. $ erl -mnesia dir my_location
  13. Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe]
  14. [kernel-poll:false]
  15. Eshell V5.5.5 (abort with ^G)
  16. 1> mnesia:create_schema([node()]).
  17. ok
  18. 2> mnesia:start().
  19. ok
  20. 3>
  21. mnesia:create_table(order,[{disc_copies,[node()]},{attributes,[id,customerid,inputfile,creationdate,
  22. finisheddate,duedate,quantity]}]).
  23. {atomic,ok}
  24. 4>
  25. Look at mnesia user’s guide for my information about schema operations.
  27. Regards,
  28. Nicolas Charpentier

Thanks, Nicolas Charpentier! :)

I tried to provide the path to the mnesia dir through my start script but that didn’t went that well, so just for kicks I changed disc_copies to ram_copies, recompiled and
got this when starting yaws:
=INFO REPORT== 4-Dec-2008::19:35:34 =
Starting yapp
=INFO REPORT== 4-Dec-2008::19:35:35 =
Inserting App yapp in Url “/yapp”
=INFO REPORT== 4-Dec-2008::19:35:35 =
Updating sconf for server http://myinternalserver:8001
=INFO REPORT== 4-Dec-2008::19:35:35 =
Keeping conf for http://myexternalserver:8000 intact

That solved it! The yapp manager is now available under http://myinternalserver:8001/yapp.
Well… ram_copies is nice and all but I’d like a more persistent storage. Let’s get disc_copies to work again figuring out how to pass the mnesia dir.

<20 minutes break>

The available ways to set the mnesia dir are:
1) Directly via erlang:
erl -mnesia dir ‘“c:/mnesia”’
%% that’s a single quote followed by a double quote to start the string and the opposite to close the string
2) When starting Yaws:
yaws -M mnesiadir (can be a relative path)
3) Via the yaws configuration file:
mnesia_dir = c:/teste

Using any of these we get this:
1> mnesia:system_info(directory).

Or almost. We just have to run:
This will create the mnesia schema on the directory we just specified.


Something went wrong with that request. Please try again.