Skip to content
Paul Schoenfelder edited this page Mar 20, 2014 · 1 revision

Ok, so you've generated a release, deployed it to your target system, made some code changes in development, and now you want to generate a release package that will allow you to do a hot upgrade. In order to do this, you must create a project.appup file, which will go in the ebin directory of your production build. There is no real clear example of how this is supposed to be built, so the following example is intended to help you get started with these. For more complicated application upgrades, you'll want to check out the Appup Cookbook.

Given a sample application called test, with a supervisor (test_sup), and a gen_server (test_server), you should have a test.app file in ebin that looks something like the following:

{application,test,
             [{registered,[]},
              {description,"test app"},
              {mod,{test,[]}},
              {applications,[stdlib,kernel]},
              {vsn,"0.0.1"},
              {modules,[test,test_server,
                        test_sup]}]}.

If you make code changes to, test_server for instance, the following is a simple appup file that will load your project's application, and call code_change on both test_sup and test_server. The first "0.0.1" block is the order of operations for the upgrade, the second one is the order of operations for the downgrade (note that it's in reverse order of the upgrade process).

{"0.0.2",
 [{"0.0.1",
   [{load_module,test},
    {update,test_server,infinity,
            {advanced,[]},
            brutal_purge,brutal_purge,[]},
    {update,test_sup,supervisor}]}],
 [{"0.0.1",
   [{update,test_sup,supervisor},
    {update,test_server,infinity,
            {advanced,[]},
            brutal_purge,brutal_purge,[]},
    {load_module,test}]}]}.

This is the simplest case for an appup, but it should cover you for common upgrade scenarios. For anything more complicated, I encourage you to read the Appup Cookbook, to fully understand each of the options for the upgrade process. Note that the {advanced, []} tuple in each of the blocks is where you would pass additional arguments to code_change, if needed.

To generate an upgrade release, you'll need to pass --upfrom "0.0.1" to relx (using the example from above), to tell it where to look for the previous release, and it will look for the appup in the ebin of your current build.

Clone this wiki locally