【发布时间】:2012-08-06 06:09:09
【问题描述】:
如何在我的 Erlang 应用程序中安装 Yaws 作为 Rebar 依赖项?
谢谢,
LRP
【问题讨论】:
如何在我的 Erlang 应用程序中安装 Yaws 作为 Rebar 依赖项?
谢谢,
LRP
【问题讨论】:
首先,确保您使用的是最新版本的 rebar,例如 2012 年 4 月或之后的版本(rebar commit dc472b 或更高版本),因为在 2012 年初对其进行了更改,专门用于支持项目像 Yaws。
要将 Yaws 用作依赖项,请在 rebar.config 文件中指定以下内容:
{deps, [{yaws, ".*", {git, "git://github.com/klacke/yaws", {branch, "master"}}}]}.
如果您愿意,可以将 {branch, "master"} 部分替换为特定的 Yaws 标签:
{deps, [{yaws, ".*", {git, "git://github.com/klacke/yaws", {tag, "yaws-1.94"}}}]}.
但请注意,我不建议使用低于 Yaws 1.94 的版本,因为专门针对 rebar 构建支持对 Yaws 进行了更改。
您实际运行 Yaws 的方式取决于您的应用程序如何使用它。在an embedded fashion 中使用它可能最适合rebar 构建的应用程序,因为这样您就不会对yaws.conf 文件有任何依赖。但是如果你想将 Yaws 作为一个独立的 web 服务器运行,你可以构建你的依赖项和你的应用程序,然后 run Yaws interactively 像这样:
rebar get-deps compile
./deps/yaws/bin/yaws -i -pa ebin
这使用./deps/yaws/etc/yaws/yaws.conf 中的默认yaws.conf 文件,您可以根据需要对其进行修改。以这种方式启动 Yaws 不会在加载路径中包含应用程序的任何其他 rebar 依赖项的 ebin 目录,但您可以使用额外的 -pa 选项添加必要的路径到 Yaws,或通过 specifying them in the yaws.conf file。
【讨论】:
make 来构建 Yaws? Yaws 支持自动工具和钢筋,但钢筋没有make 目标。您需要直接运行 rebar compile 来使用 rebar 构建 Yaws。
rebar get-deps compile,它下载了 yaws-1.99 并构建了它,没问题。运行rebar --version 显示rebar 2.5.1 R14B04 20141216_212600 git 2.5.1-57-gb796065。这是专门从 2014 年 12 月上旬的 git 版本 b796065 构建的,因为目前(截至 2015 年 1 月 18 日)更新的版本不适用于 Yaws。