CouchDB作为Erlang发行版的一部分 [英] CouchDB as a part of an Erlang release

查看:252
本文介绍了CouchDB作为Erlang发行版的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建并部署应用程序Django作为前端,YAWS( appmods )或Mochiweb / Webmachine作为后端,CouchDB作为数据存储。此外,我打算广泛使用CouchDB复制的能力,以便为整个应用程序提供高容错。

I would like to build and deploy an application which has Django as frontend, YAWS (appmods) or Mochiweb/Webmachine as a backend and CouchDB as a datastore. Furthermore, I plan to extensively use CouchDB's ability to replicate in order to provide high fault tolerance for the whole application.

我倾向于认为为了实现这一点,我必须创建一个单独的OTP版本,它具有YAWS和CouchDB作为Erlang / OTP应用程序。

I tend to think that in order to achieve this, I must create a single OTP release which has YAWS and CouchDB as Erlang/OTP applications.

这种方法似乎是正确的吗?在OTP应用方面如何组织YAWS和CouchDB以创建稳固的生产设置?有没有最好的做法?

Does this approach seem to be correct? How can I organize YAWS and CouchDB in terms of OTP applications in order to create a solid production setup? Are there any best practices for doing that?

推荐答案

Erlang发布是打包软件的好方法,因为它包括所有依赖库。这样,不同的erlang应用程序可以运行不同版本的所需库,而不会相互冲突。

Erlang releases are a good way to package software, because they include all of the dependent libraries. This way, different erlang applications can run different versions of their required libraries without conflicting with each other.

处理复杂的发布过程的流行方式Erlang有让 Rebar 为您做。他们有一个快速入门指南,让您走上正确的道路。我不知道你目前是否正在使用Rebar来管理你的项目,但是它使事情变得容易多了。如果您还没有使用它,这绝对值得研究。

A popular way of dealing with the complicated release process Erlang has is to let Rebar do it for you. They have a quick start guide to get you on the right path. I don't know if you're currently using Rebar to manage your project, but it makes things a lot easier. It is definitely worth looking into if you aren't using it yet.

然而,钢筋不会包含您的依赖项。为了做到这一点,你应该修改reltool.config文件和你所需的所有应用程序。

However, rebar won't include your dependencies right out of the box. In order to do that, you should modify the reltool.config file and all your required applications.

第一步是添加所有依赖项所在的目录,例如:

First step is to add the directory where all your dependencies are located, e.g.:

{sys, [
    ...
    {lib_dirs, ["../deps"]},
    ...
}.

然后,将附件作为应用程序添加到发行版中:

Then, add your dependencies as applications to include in the release:

{sys, [
    ...
    {app, jiffy, [{incl_cond, include}]},
    {app, cowboy, [{incl_cond, include}]},
    ...
}.

现在,当您运行钢筋生成命令,您的应用程序应该位于lib目录下:

Now, when you run the rebar generate command, your applications should be in the target directory under lib:

find brawl_server -type d -maxdepth 2

brawl_server
brawl_server/bin
brawl_server/erts-5.9.1
brawl_server/erts-5.9.1/bin
brawl_server/lib
brawl_server/lib/brawl_server-1.1
brawl_server/lib/cowboy-0.6.0
brawl_server/lib/jiffy-0.6.1
brawl_server/lib/kernel-2.15.1
brawl_server/lib/sasl-2.2.1
brawl_server/lib/stdlib-1.18.1
brawl_server/log
brawl_server/log/sasl
brawl_server/releases
brawl_server/releases/1

您还需要确保自己的OTP应用程序知道需要启动它所依赖的应用程序。如果您有生成的Rebar项目,请修改< appname> .app.src 文件以包含它们:

You also need to make sure your own OTP application knows it needs to start the applications it depends on. If you have a generated Rebar project, modify your <appname>.app.src file to include them:

{application, app, [
    ...
    {applications, [
              jiffy,
              cowboy,
              kernel,
              stdlib
             ]},
    ...
}.

您应该能够编译和生成发行版,并使用附带的脚本运行,如在钢筋释放处理文章中。

You should be able to compile and generate the release and run it with the included scripts, as laid out in the Rebar release handling article.

尽管如此,还有一个额外的皱纹,因为显然香草CouchDB不符合OTP标准,您不能包含它这条路。您可以使用另一种分发方式: rcouch 。我没有尝试过,希望能为你工作。

At this point, though, there's an added wrinkle, because apparently vanilla CouchDB isn't OTP compliant, and you can't include it this way. There is another distribution you may be able to use, instead: rcouch. I haven't tried it myself, hopefully it will work for you.

进一步阅读:

  • Learn you some erlang for great good: Releases
  • I used my own project, brawl-online, as an example

这篇关于CouchDB作为Erlang发行版的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆