- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
好吧,我做错了什么。我正在尝试来自 http://yaws.hyber.org/embed.yaws 的嵌入式 YAW 的简单示例但是有一个appmod。我添加了 my_app.erl 文件并编译了它。如果不是在嵌入式 YAW 中,它也能工作,所以我认为它是特定于嵌入式的。
-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()}.
出现此错误:
ERROR erlang code threw an 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}]}]
最佳答案
堆栈跟踪显示您的 my_app:out/1
函数正在被调用,但是您遇到了一个 undef
异常。发生这种情况是因为运行时找不到 my_app:out/1
函数,这意味着它找不到模块或模块存在但不导出 out/1
功能。例如,通过不提供 my_app
模块,我能够使用示例代码复制错误。
首先,确保您的 my_app.erl
文件导出一个 out/1
函数。这是一个简单的请求,它只为所有请求返回 405 错误:
-module(my_app).
-export([out/1]).
out(_Arg) ->
{status, 405}.
编译你的 my_app.erl
文件并将编译后的 my_app.beam
文件放在 Erlang 运行时已知的加载路径中,或者放在你添加到的目录中加载路径。在您的代码中,您似乎正在尝试后一种方法,因为您专门使用此 Yaws 全局配置指令添加了 ebin_dir
:
GconfList = [{ebin_dir, ["/Users/someuser/yawsembedded/ebin"]}],
您需要验证 /Users/someuser/yawsembedded/ebin
目录存在,并且已编译的 my_app.beam
文件位于该目录中。
关于erlang - 嵌入了 appmod 的 YAW 对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32303424/
Appmods 是一种让应用程序程序员控制 URL 路径的方法。它们被实现为 Erlang 模块。例如myappmod.erl -module(myappmod). -include("../../y
我正在尝试管理 Yast appmod。所以: 雅司病.conf: port = 8005 listen = 127.0.0.1 docroot = /home/ziel/www/
我在生产环境中将 YAWS 嵌入到我的应用程序中,并使用函数 yaws:start_embedded/4 来启动 YAWS。 下面是我的代码: Id = "my_server", GconfList
好吧,我做错了什么。我正在尝试来自 http://yaws.hyber.org/embed.yaws 的嵌入式 YAW 的简单示例但是有一个appmod。我添加了 my_app.erl 文件并编译了它
我是一名优秀的程序员,十分优秀!