Good practices when developing an application in E

2019-01-30 04:00发布

问题:

We are in the process of getting familiar with Erlang/OTP and Riak (Core, KV, Pipe, and so on) in view of developing an open-source distributed application in turn. Our project is going to have a bunch of dependencies : tools like erlang_js, protobuffs, etc., but also services that we need to have running, such as Riak KV.

In Python/Ruby/Node.js, if modules are placed in a standard subdirectory relative to your project's, you can reference them, and later package them in releases. You can fire up a shell in the project's directory, play with your modules, do tests and so on, all just easily if good practices are followed.

What are the best practices for organizing a development environment in Erlang/OTP, with all dependencies reachable (and easily updatable to newest version), shell access to running nodes, testing, making releases, and so forth?

回答1:

Check out rebar: https://github.com/basho/rebar used for packaging, templating and managing releases of Erlang/OTP applications. You will find there an entire tutorial on how to use it.

Check out this tutorial on OTP first, before you can switch to this one which shows you releases and how they are handled in Erlang. Use this entire book as reference as you develop your project and because the author is still progressively adding more advanced stuff that you may need.

You may also want to keep reading about Erlang Applications and then do check out these quick links below:

Erlang Packaging, Process One
OTP Packaging Video by Chicago Boss Guys
Erlang Dependency Management
Richard Jones Advice and examples on Packaging Erlang Projects with Dependencies
Maven Tool and how it is used in packaging Erlang Projects

Most importantly, take rebar very seriously ! It is very important in managing Erlang applications which have dependencies. You can keep Posting your questions here on stackoverflow for any assistance as you progress.

Before i forget, do check out alot of stuff from the Riak Community

EDIT

Also, its important to check out the system documentation on creating target systems and also how to use Reltool to handle releases. The good thing with erlang is that it has several options of how to do something, as long as its easy to maintain your application in that way. With target systems, you will learn how to embed the Erlang VM, how to run Erlang applications on Solaris, VxWorks,and creating Erlang applications as Services on Windows NT using erlsrv.

Normally, we make sure that as an operating system is booting a Server, our application starts with it. Solaris is so far has more customizations than any other OS as regards embedding Erlang/OTP VM. You can always communicate with (an) embedded Erlang VM(s) using Escript where by the escript creates a an erlang node which is allowed to connect to the embedded VM (so they have to share same cookie) and the embedded VM must have allowed the temporarily created Node to connect by executing

net_kernel:allow(List_of_nodes)
, you make sure to call this method to make your embedded VM allow connections only from an known strictly specified number of Nodes.



标签: erlang otp riak