erlang - YAWs embedded with appmod not working for me -


alright, doing wrong here. i'm trying simple example of embedded yaws http://yaws.hyber.org/embed.yaws appmod. i've added my_app.erl file , compiled it. works if not in embedded yaws think specific embedded.

-module(ybed). -compile(export_all).  start() ->     {ok, spawn(?module, run, [])}.  run() ->     id = "embedded",     gconflist = [{ebin_dir, ["/users/someuser/yawsembedded/ebin"]}],     docroot = "/users/someuser/yawstest",     sconflist = [{port, 8888},                  {listen, {0,0,0,0}},                  {docroot, docroot},                  {appmods, [{"/", my_app}]}                 ],     {ok, sclist, gc, childspecs} =         yaws_api:embedded_start_conf(docroot, sconflist, gconflist),     [supervisor:start_child(ybed_sup, ch) || ch <- childspecs],     yaws_api:setconf(gc, sclist),     {ok, self()}. 

getting error:

error erlang code threw uncaught exception:  file: appmod:0 class: error exception: undef req: {http_request,'get',{abs_path,"/demo"},{1,1}} stack: [{my_app,out,             [{arg,#port<0.2721>,                  {{127,0,0,1},63720},                  {headers,"keep-alive",                      "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",                      "0.0.0.0:8888",undefined,undefined,undefined,undefined,                      undefined,undefined,undefined,                      "mozilla/5.0 (macintosh; intel mac os x 10.10; rv:40.0) gecko/20100101 firefox/40.0",                      undefined,[],undefined,undefined,undefined,undefined,                      undefined,undefined,undefined,undefined,                      [{http_header,0,"dnt",undefined,"1"},                       {http_header,10,'accept-encoding',undefined,                           "gzip, deflate"},                       {http_header,11,'accept-language',undefined,"null"}]},                  {http_request,'get',{abs_path,"/demo"},{1,1}},                  {http_request,'get',{abs_path,"/demo"},{1,1}},                  undefined,"/demo",undefined,undefined,                  "/users/someuser/yawstest","/",                  "/users/someuser/yawstest/demo",undefined,undefined,                  <0.63.0>,[],"/","/",undefined}],             []},         {yaws_server,deliver_dyn_part,8,             [{file,"yaws_server.erl"},{line,2818}]},         {yaws_server,aloop,4,[{file,"yaws_server.erl"},{line,1232}]},         {yaws_server,acceptor0,2,[{file,"yaws_server.erl"},{line,1068}]},         {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}] 

the stack trace shows my_app:out/1 function getting called, you're getting undef exception. occurring because runtime can't find my_app:out/1 function, means either can't find module or module exists not export out/1 function. example, able duplicate error using example code not providing my_app module.

first, make sure my_app.erl file exports out/1 function. here's trivial 1 returns 405 error requests:

-module(my_app). -export([out/1]).  out(_arg) ->     {status, 405}. 

compile my_app.erl file , put compiled my_app.beam file either in load path known erlang runtime, or in directory add load path. in code appears you're trying latter approach, since you're adding ebin_dir yaws global configuration directive:

gconflist = [{ebin_dir, ["/users/someuser/yawsembedded/ebin"]}], 

you need verify /users/someuser/yawsembedded/ebin directory exists, , compiled my_app.beam file located there.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -