0

我在这里是因为我试图在 YAWS 上使用 Couchbeam 表单。我已经测试了 CB,它在终端上正常工作,使用:

erl -pa ebin -pa deps/ibrowse/ebin -s couchbeam

现在我正在尝试在我的网页上复制我在本地所做的事情。我相信问题是我不知道如何告诉 erl 从 yaws 页面执行 'erl -pa ebin -pa deps/ibrowse/ebin -s couchbeam'。

我试图简单地运行所有需要的应用程序,但我得到了这个:

Stack: [{ibrowse_lib,url_encode,["test"],[]},
{couchbeam,save_doc,3,[{file,"src/couchbeam.erl"},{line,383}]},
{m50,out,1,
     [{file,"/Users/Nesh/.yaws/yaws/default/m50.erl"},{line,35}]},
{yaws_server,deliver_dyn_part,8,
             [{file,"yaws_server.erl"},{line,2647}]},
{yaws_server,aloop,4,[{file,"yaws_server.erl"},{line,1152}]},
{yaws_server,acceptor0,2,[{file,"yaws_server.erl"},{line,1013}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]

这是我的erl代码:

<erl>


 startApp() ->
 application:start(crypto),
 application:start(private_key),
 application:start(ssl),
 application:start(sasl), 
 application:start(ibrowse),
 application:start(couchbeam).



out(Arg) ->
startApp(),

Host = "localhost",
Port = 5984,
Prefix = "",
Options = [],
S = couchbeam:server_connection(Host, Port, Prefix, Options),

Options = [],{ok, Db} = couchbeam:open_db(S, "erlang", Options),

Doc = {[{<<"_id">>, <<"test">>},{<<"content">>, <<"web text">>}]},
{ok, Doc1} = couchbeam:save_doc(Db, Doc).


</erl>
4

2 回答 2

1

我不建议在这样的 .yaws 页面中运行 Couchbeam。相反,您应该创建一个 Erlang 版本,以便 Couchbeam 和 Yaws 在同一个 Erlang VM 中执行,然后使用Yaws appmod调用 Couchbeam,或者您应该考虑将 Couchbeam作为 Yaws 的引导 yapp

如果你真的认为你有加载路径问题,你可以通过指令在yaws.conf文件中指定加载路径。ebin_dir例如:

ebin_dir = deps/ibrowse/bin
ebin_dir = couchbeam/ebin

但是您显示的堆栈跟踪似乎缺少某些内容,因此很难确切地告诉您出了什么问题。

于 2012-09-18T01:54:17.633 回答
0

我设法修复它这样做:

我在 yaws.conf 中添加了这些行:

ebin_dir = /usr/local/var/yaws/couchbeam/deps/ibrowse/ebin
ebin_dir = /usr/local/var/yaws/couchbeam/deps/jiffy/ebin
ebin_dir = /usr/local/var/yaws/couchbeam/deps/mochiweb/ebin
ebin_dir = /usr/local/var/yaws/couchbeam/ebin

注意:我将文件夹“couchbeam”放在 /usr/local/var/yaws/

然后我以这种方式修改了代码:

load_deps() ->

application:start(sasl),
application:start(ibrowse),
application:start(jiffy),
application:start(inets),
application:start(xmerl),
application:start(compiler),
application:start(syntax_tools),
application:start(mochiweb),
application:start(couchbeam).


out(Arg) ->

load_deps(),
Host = "localhost",
Port = 5984,
Prefix = "",
Options = [],
S = couchbeam:server_connection(Host, Port, Prefix, Options),

Options = [],{ok, Db} = couchbeam:open_db(S, "erlang", Options),

Doc = {[{<<"content">>, <<"Checking webpage">>}]},
{ok, Doc1} = couchbeam:save_doc(Db, Doc),

{html, "Document has been added"}.


</erl>
于 2012-09-18T07:36:11.847 回答