RELXA Dead Simple Way to Build ReleasesTuesday, June 18, 13
TopicsThe basics of OTP Applications and ReleasesWhy Releases are importantHow Relx builds ReleasesHow different Relx opti...
GoalWalk out of this talk with the abilityto create and use releases.Tuesday, June 18, 13
What is RelxTool designed to build releasesDesigned to integrate into a unix like suite of build toolsTuesday, June 18, 13
OTP Application RefresherWell defined structureWell defined lifecycle (start, stop, semantics)Useful metadata (including a...
Well Defined Structure!"" <name>-<version>!"" ebin# $"" <name>.app!"" doc!"" priv!"" include$"" srcTuesday, June 18, 13
Well Defined Lifecycle-module(echo_get_app).-behaviour(application).%% API.-export([start/2,stop/1]).-include("echo_get.hr...
Useful Metadata{application,echo_get,[{description,"Cowboy GET echo example."},{vsn,"0.0.0+build.1.ref5b05dba"},{modules,[...
How We Start Applications-module(echo_get).%% API.-export([manual_start/0]).%%%===========================================...
How We Start Applications#!/bin/sherl -noshell -pa ebin deps/*/ebin -s echo_get manual_start -eval "io:format("Point your ...
What Do We Have?An Erlang System where dependency information is hap hazard(in at least two places, one of which is ignore...
Current State of the WorldLots of systems are assembled poorly (ie, poorly organized, not using theright abstractions, pro...
What is NeededSomething that manages and provides clear semantics around systemstartup and shutdownSomething that uses the...
We Have It!Something that manages and provides clear semantics around systemstartup and shutdown - Erlang/OTP ReleasesSome...
What Exactly is a ReleaseA Set of built, versioned OTP ApplicationsMetadata that describes applications requiredAn explici...
Release OverviewTuesday, June 18, 13
Release Metadata{release,{"echo_get","0.0.1"},{erts,"5.10.1"},[{kernel,"2.16.1"},{stdlib,"1.19.1"},{ranch,"0.8.3"},{crypto...
Release Structure!"" bin!"" echo_get$"" echo_get-0.0.1!"" erts-5.10.1!"" lib#   !"" cowboy-0.8.5#   !"" crypto-2.3#   !"" ...
Creating A Release>relxStarting relx build process ...Resolving OTP Applications from directories:/Users/emerrit/workspace...
What Relx DoesReads the configurationDiscovers the environment (Apps and Releases available)Starting at the apps and const...
Configuration%% -*- mode: Erlang; fill-column: 80 -*-{release, {echo_get, "0.0.1"},[echo_get]}.Tuesday, June 18, 13
An Example (echo_get){application,echo_get,[{description,"Cowboy GET echo example."},{vsn,"0.0.0+build.1.ref5b05dba"},{mod...
echo_get Release Structure!"" bin!"" echo_get$"" echo_get-0.0.1!"" erts-5.10.1!"" lib#   !"" cowboy-0.8.5#   !"" crypto-2....
Constraining%% -*- mode: Erlang; fill-column: 80 -*-{release, {echo_get, "0.0.1"},[echo_get,sasl]}.Tuesday, June 18, 13
Constraining%% -*- mode: Erlang; fill-column: 80 -*-{release, {echo_get, "0.0.1"},[echo_get,{sasl, “2.3”, gte}]}.Tuesday, ...
App Overrides{overrides,	  [{sexpr,	  "../sexpr"}]}.Tuesday, June 18, 13
Overlays{overlay_vars,	  "vars.config"}.{overlay,	  [{mkdir,	  "log/sasl"},	  	  	  	  	  	  	  	  	  	  	  	  {copy,	  "f...
Multiple Releases%% -*- mode: Erlang; fill-column: 80 -*-{release, {echo_get, "0.0.1"},[{echo_get, “0.0.1”}]}.{release, {e...
Easily ExtendableSimply implement the rlx_provider behaviourApi for accessing and manipulating releases via rlx_state, rlx...
Implementing a Provider-­‐callback	  init(rlx_state:t())	  -­‐>	  	  	  	  	  	  	  	  	  {ok,	  rlx_state:t()}	  |	  relx...
Adding Providers{add_providers,	  [my_custom_functionality]}.Tuesday, June 18, 13
Erlware’s Relxhttp://relx.orghttp://erlware.orgTuesday, June 18, 13
August 30th - 31sthttp://erlangcamp.comTuesday, June 18, 13
October 11th - 12thhttp://erlangcamp.comTuesday, June 18, 13
Questions??Tuesday, June 18, 13
Upcoming SlideShare
Loading in...5
×

EUC 2013 - Relx

469

Published on

A dead simple way to build releases

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
469
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

EUC 2013 - Relx

  1. 1. RELXA Dead Simple Way to Build ReleasesTuesday, June 18, 13
  2. 2. TopicsThe basics of OTP Applications and ReleasesWhy Releases are importantHow Relx builds ReleasesHow different Relx options affect the built ReleaseHow to extend RelxTuesday, June 18, 13
  3. 3. GoalWalk out of this talk with the abilityto create and use releases.Tuesday, June 18, 13
  4. 4. What is RelxTool designed to build releasesDesigned to integrate into a unix like suite of build toolsTuesday, June 18, 13
  5. 5. OTP Application RefresherWell defined structureWell defined lifecycle (start, stop, semantics)Useful metadata (including an explicit dependency graph)Basic Building Blocks of Erlang SystemsTuesday, June 18, 13
  6. 6. Well Defined Structure!"" <name>-<version>!"" ebin# $"" <name>.app!"" doc!"" priv!"" include$"" srcTuesday, June 18, 13
  7. 7. Well Defined Lifecycle-module(echo_get_app).-behaviour(application).%% API.-export([start/2,stop/1]).-include("echo_get.hrl").%%%===================================================================%%% API%%%===================================================================start(_Type, _Args) ->Dispatch = cowboy_router:compile(?DISPATCH),{ok, _} = cowboy:start_http(http, 100,[{port, 8080}],[{env,[{dispatch, Dispatch}]}]),echo_get_sup:start_link().stop(_State) ->ok.Tuesday, June 18, 13
  8. 8. Useful Metadata{application,echo_get,[{description,"Cowboy GET echo example."},{vsn,"0.0.0+build.1.ref5b05dba"},{modules,[echo_get,echo_get_app,echo_get_handler,echo_get_sup]},{registered,[]},{applications,[kernel,stdlib,ranch,cowboy]},{mod,{echo_get_app,[]}},{env,[]}]}.Tuesday, June 18, 13
  9. 9. How We Start Applications-module(echo_get).%% API.-export([manual_start/0]).%%%===================================================================%%% API%%%===================================================================manual_start() ->ok = application:start(crypto),ok = application:start(ranch),ok = application:start(cowboy),ok = application:start(echo_get).Tuesday, June 18, 13
  10. 10. How We Start Applications#!/bin/sherl -noshell -pa ebin deps/*/ebin -s echo_get manual_start -eval "io:format("Point your browser at http://localhost:8080/?echo=test~n")."Tuesday, June 18, 13
  11. 11. What Do We Have?An Erlang System where dependency information is hap hazard(in at least two places, one of which is ignored)A system that trusts the programmer to manually startup thingsin the right order (without leaving anything out)A system where its component parts are spread around the OSfilesystem (if we are lucky and they are even there)Tuesday, June 18, 13
  12. 12. Current State of the WorldLots of systems are assembled poorly (ie, poorly organized, not using theright abstractions, prone to failure)Commonly deploy by simply manually copying the Apps and then running ascript that starts it (which also starts its dependencies manually)Dependencies described and handled outside of the OTP Apps themselvesitselfTuesday, June 18, 13
  13. 13. What is NeededSomething that manages and provides clear semantics around systemstartup and shutdownSomething that uses the dependencies described and manages where theyoccur and when they are startedSomething that does the creation and packaging and of Erlang Systemsleveraging all that metadataSomething to startup and manage systemsTuesday, June 18, 13
  14. 14. We Have It!Something that manages and provides clear semantics around systemstartup and shutdown - Erlang/OTP ReleasesSomething that uses the dependencies described and manages where theyoccur and when they are started - Erlang/OTP ReleaseSomething that does the creation and packaging and of Erlang Systemsleveraging all that metadata - Erlware’s RelxSomething to startup and manage systems - Erlang/OTP Releaseor How to Build Systems the Right wayTuesday, June 18, 13
  15. 15. What Exactly is a ReleaseA Set of built, versioned OTP ApplicationsMetadata that describes applications requiredAn explicit configuration mechanismOptionally tarballs that can be managed and deployedTuesday, June 18, 13
  16. 16. Release OverviewTuesday, June 18, 13
  17. 17. Release Metadata{release,{"echo_get","0.0.1"},{erts,"5.10.1"},[{kernel,"2.16.1"},{stdlib,"1.19.1"},{ranch,"0.8.3"},{crypto,"2.3"},{cowboy,"0.8.5"},{echo_get,"0.0.1"}]}.Tuesday, June 18, 13
  18. 18. Release Structure!"" bin!"" echo_get$"" echo_get-0.0.1!"" erts-5.10.1!"" lib#   !"" cowboy-0.8.5#   !"" crypto-2.3#   !"" echo_get-0.0.0+build.1.ref5b05dba#   !"" kernel-2.16.1#   !"" ranch-0.8.3#   $"" stdlib-1.19.1$"" releases$"" echo_get-0.0.1!"" echo_get.boot!"" echo_get.rel!"" echo_get.script!"" sys.config$"" vm.argsTuesday, June 18, 13
  19. 19. Creating A Release>relxStarting relx build process ...Resolving OTP Applications from directories:/Users/emerrit/workspace/EUC2013/echo_get/ebin/Users/emerrit/workspace/EUC2013/echo_get/deps/usr/local/Cellar/erlang/R16B/lib/erlang/libResolving available releases from directories:/Users/emerrit/workspace/EUC2013/echo_get/ebin/Users/emerrit/workspace/EUC2013/echo_get/deps/usr/local/Cellar/erlang/R16B/lib/erlang/libResolved echo_get-0.0.1release successfully created!Tuesday, June 18, 13
  20. 20. What Relx DoesReads the configurationDiscovers the environment (Apps and Releases available)Starting at the apps and constraints specified - does a constraintsolve to resolve the full dependency treeUses that information to assemble the releaseCreates the release, including all metadata and support functionsTuesday, June 18, 13
  21. 21. Configuration%% -*- mode: Erlang; fill-column: 80 -*-{release, {echo_get, "0.0.1"},[echo_get]}.Tuesday, June 18, 13
  22. 22. An Example (echo_get){application,echo_get,[{description,"Cowboy GET echo example."},{vsn,"0.0.0+build.1.ref5b05dba"},{modules,[echo_get,echo_get_app,echo_get_handler,echo_get_sup]},{registered,[]},{applications,[kernel,stdlib,ranch,cowboy]},{mod,{echo_get_app,[]}},{env,[]}]}.Tuesday, June 18, 13
  23. 23. echo_get Release Structure!"" bin!"" echo_get$"" echo_get-0.0.1!"" erts-5.10.1!"" lib#   !"" cowboy-0.8.5#   !"" crypto-2.3#   !"" echo_get-0.0.0+build.1.ref5b05dba#   !"" kernel-2.16.1#   !"" ranch-0.8.3#   $"" stdlib-1.19.1$"" releases$"" echo_get-0.0.1!"" echo_get.boot!"" echo_get.rel!"" echo_get.script!"" sys.config$"" vm.argsTuesday, June 18, 13
  24. 24. Constraining%% -*- mode: Erlang; fill-column: 80 -*-{release, {echo_get, "0.0.1"},[echo_get,sasl]}.Tuesday, June 18, 13
  25. 25. Constraining%% -*- mode: Erlang; fill-column: 80 -*-{release, {echo_get, "0.0.1"},[echo_get,{sasl, “2.3”, gte}]}.Tuesday, June 18, 13
  26. 26. App Overrides{overrides,  [{sexpr,  "../sexpr"}]}.Tuesday, June 18, 13
  27. 27. Overlays{overlay_vars,  "vars.config"}.{overlay,  [{mkdir,  "log/sasl"},                        {copy,  "files/erl",  "{{erts_vsn}}/bin/erl"},                        {copy,  "files/nodetool",  "{{erts_vsn}}/bin/nodetool"},                        {template,  "files/app.config",  "etc/app.config"},                        {template,  "files/vm.args",  "etc/vm.args"}]}.Tuesday, June 18, 13
  28. 28. Multiple Releases%% -*- mode: Erlang; fill-column: 80 -*-{release, {echo_get, "0.0.1"},[{echo_get, “0.0.1”}]}.{release, {echo_get, "0.0.2"},[{echo_get, “0.0.2”]}.Tuesday, June 18, 13
  29. 29. Easily ExtendableSimply implement the rlx_provider behaviourApi for accessing and manipulating releases via rlx_state, rlx_release andrlx_app_infoTuesday, June 18, 13
  30. 30. Implementing a Provider-­‐callback  init(rlx_state:t())  -­‐>                  {ok,  rlx_state:t()}  |  relx:error().-­‐callback  do(rlx_state:t())  -­‐>                    {ok,  rlx_state:t()}  |  relx:error().-­‐callback  format_error(Reason::term())  -­‐>                  iolist().Tuesday, June 18, 13
  31. 31. Adding Providers{add_providers,  [my_custom_functionality]}.Tuesday, June 18, 13
  32. 32. Erlware’s Relxhttp://relx.orghttp://erlware.orgTuesday, June 18, 13
  33. 33. August 30th - 31sthttp://erlangcamp.comTuesday, June 18, 13
  34. 34. October 11th - 12thhttp://erlangcamp.comTuesday, June 18, 13
  35. 35. Questions??Tuesday, June 18, 13
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×