17.01.2015 Views

Erlang and OTP in Action.pdf - Synrc

Erlang and OTP in Action.pdf - Synrc

Erlang and OTP in Action.pdf - Synrc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

256<br />

As you can see all of the application dependencies listed <strong>in</strong> our simple_cache.rel file are<br />

up <strong>and</strong> runn<strong>in</strong>g except stdlib which is a library app. So there we have it, a runn<strong>in</strong>g <strong>Erlang</strong><br />

service. Bravo! In the next section we will take what we have learned here <strong>and</strong> further its<br />

usefulness by learn<strong>in</strong>g howt to package up a Release for easier <strong>in</strong>stallation <strong>and</strong> deployment.<br />

10.3.3 – Release Packag<strong>in</strong>g<br />

What more can we do with releases Well, we can package them up for easy <strong>in</strong>stallation,<br />

distribution, <strong>and</strong> deployment. <strong>OTP</strong> provides some helpful functionality for packag<strong>in</strong>g releases,<br />

but not all the functionality required for a production grade package. This is a hole <strong>in</strong> the <strong>OTP</strong><br />

functionality <strong>and</strong> one where the community at large has had to pick up where <strong>OTP</strong> left off.<br />

For this reason we will show you a more complete process that has ga<strong>in</strong>ed some traction <strong>in</strong><br />

the community but is not an official <strong>OTP</strong> st<strong>and</strong>ard. We will start off the process of creat<strong>in</strong>g a<br />

Release package with the <strong>OTP</strong> provided functionality. We are go<strong>in</strong>g to do that by runn<strong>in</strong>g<br />

another tool <strong>in</strong> the systools module. The make_tar function. As you may guess make_tar<br />

produces a tarball represent<strong>in</strong>g a component of our overall Release package. Lets dig <strong>in</strong> <strong>and</strong><br />

run that now.<br />

>> erl -pa ./simple_cache/eb<strong>in</strong> -pa ./resource_discovery/eb<strong>in</strong><br />

<strong>Erlang</strong> R1301 (ERTS-5.7.2) [source] [64-bit] [smp:2:2] [rq:2] [asyncthreads:0]<br />

[kernel-poll:false]<br />

Eshell V5.7.2 (abort with ^G)<br />

1> systools:make_tar("simple_cache").<br />

ok<br />

2><br />

If you list what’s <strong>in</strong> the releases directory now you will see a new file called<br />

‘simple_cache.tar.gz’. That’s the tarball that conta<strong>in</strong>s a portion of our new Release.<br />

Let’s take a look at what’s <strong>in</strong>side the tarball. It should be pretty <strong>in</strong>formative about what<br />

<strong>Erlang</strong>/<strong>OTP</strong> cares about.<br />

>> mkdir tmp<br />

>> mv simple_cache.tar.gz tmp<br />

>> cd tmp<br />

>> tar –xzf simple_cache.tar.gz<br />

>> ls<br />

lib releases<br />

>> ls lib<br />

kernel-2.13.2 mnesia-4.4.10 resource_discovery-0.1.0 sasl-2.1.5.3<br />

simple_cache-0.1.0 stdlib-1.16.2<br />

>> ls releases<br />

0.1.0.4 simple_cache.rel<br />

>> ls releases/0.1.0.4<br />

start.boot<br />

©Mann<strong>in</strong>g Publications Co. Please post comments or corrections to the Author Onl<strong>in</strong>e forum:<br />

http://www.mann<strong>in</strong>g-s<strong>and</strong>box.com/forum.jspaforumID=454

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!