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.
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.
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 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.
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.
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.:
Then, add your dependencies as applications to include in the release:
Now, when you run the
rebar generate
command, your applications should be in the target directory under lib: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: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.
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.
Further reading:
I would recommend to create DEB/RPM/you-name-it package or packages. CheckInstall is the simplest solution for this.