Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Deploying Elixir

Deploying Elixir

Martin Kavalar @mkvlr and me talking about production experience of deploying Elixir projects.

Martin Schürrer

April 24, 2015
Tweet

More Decks by Martin Schürrer

Other Decks in Technology

Transcript

  1. defmodule BoldPoker do use Application def start(_type, _args) do import

    Supervisor.Spec children = [ worker(BP.TableManager, []), supervisor(BP.Client.Supervisor, []), supervisor(BP.Table.Supervisor, []) ] opts = [strategy: :one_for_one] Supervisor.start_link(children, opts) end end
  2. % mix release ==> Building release with MIX_ENV=prod. ==> Generating

    relx configuration... ==> Generating sys.config... ==> Generating boot script... ==> Performing protocol consolidation... ==> Generating revision file ==> Generating release... ==> Generating nodetool... ==> Deleting revision file ==> Packaging release... ==> The release for boldpoker_game-1.2.4 is ready!
  3. boldpoker_game-1.2.4.tar.gz ├── bin │ ├── boldpoker_game │ └── nodetool ├──

    erts-6.4 ├── lib │ ├── boldpoker_game-1.2.4 │ ├── cowboy-1.0.0 │ ├── elixir-1.0.4 │ ├── stdlib-2.4 │ └── ... └── releases ├── 1.2.4 └── RELEASES
  4. % mix release ==> Building release with MIX_ENV=prod. ==> Generating

    relx configuration... ==> Generating sys.config... ==> Generating boot script... ==> Performing protocol consolidation... ==> Generating revision file ==> Generating release... ==> Generated .appup for boldpoker_game 1.2.4 -> 1.2.5 ==> relup successfully created! ==> Generating nodetool... ==> Deleting revision file ==> Packaging release... ==> The release for boldpoker_game-1.2.5 is ready!
  5. {'1.2.5', [{'1.2.4', [], [ {:load_object_code, {:bp_game, '1.2.5', [Poker]}}, :point_of_no_return, {:load,

    {Poker, :brutal_purge, :brutal_purge}} ]}], [{'1.2.4', [], [ {:load_object_code, {:bp_game, '1.2.4', [Poker]}}, :point_of_no_return, {:load, {Poker, :brutal_purge, :brutal_purge}} ]}] } relup
  6. {'1.2.5', [{'1.2.4', [], [{:load_object_code, {:bp_game, '1.2.5', [BP.Table]}}, :point_of_no_return, {:suspend, [BP.Table]},

    {:load, {BP.Table, :brutal_purge, :brutal_purge}}, {:code_change, :up, [{BP.Table, []}]}, {:resume, [BP.Table]} ]}], [{'1.2.4', [], [{:load_object_code, {:bp_game, '1.2.4', [BP.Table]}}, :point_of_no_return, {:suspend, [BP.Table]}, {:code_change, :down, [{BP.Table, []}]}, {:load, {BP.Table, :brutal_purge, :brutal_purge}}, {:resume, [BP.Table]} ]}]} relup
  7. boldpoker_game-1.2.5.tar.gz ├── bin │ ├── boldpoker_game │ └── nodetool ├──

    erts-6.4 ├── lib │ ├── boldpoker_game-1.2.4 │ ├── boldpoker_game-1.2.5 │ ├── elixir-1.0.4 │ ├── stdlib-2.4 │ └── ... └── releases ├── 1.2.4 ├── 1.2.5 ├── RELEASES └── start_erl.data
  8. 1. Have previous release available 2. mix release
 → boldpoker_game-1.2.5.tar.gz

    3. Server: mkdir -p releases/1.2.5 4. Put the .tar.gz into releases/1.2.5/ boldpoker_game.tar.gz 5. bin/boldpoker_game upgrade "1.2.5"
  9. Out of scope for those tools • Where do I

    store my previous releases so I can build the upgrades? • Releases include native code, no way to cross- compile • Deployment to multiple servers?
  10. % ./edeliver build release Using local release store. BUILDING RELEASE

    OF BOLDPOKER_GAME APP ON BUILD HOST -----> Authorizing hosts -----> Ensuring hosts are ready to accept git pushes -----> Pushing new commits with git to: msch@localhost -----> Resetting remote hosts to 7d02ecd8a -----> Stashing build directory on remote build host -----> Fetching / Updating dependencies -----> Compiling sources -----> Generating release -----> Copying release to local release store -----> Copying boldpoker_game-1.2.0.tar.gz to release store RELEASE BUILD OF BOLDPOKER_GAME WAS SUCCESSFUL!
  11. % ./edeliver deploy release to production --version=1.2.0 Using local release

    store. DEPLOYING RELEASE OF BOLDPOKER_GAME APP TO PRODUCTION HOSTS -----> Authorizing hosts -----> Uploading archive of release 1.2.0 from local release store -----> Extracting archive boldpoker_game_1.2.0.tar.gz DEPLOYED RELEASE TO PRODUCTION!
  12. % ./edeliver start production Using local release store. EDELIVER BOLDPOKER_GAME

    WITH START COMMAND -----> starting production servers production node: user : msch host : localhost path : /opt/boldpoker-game/ Connection to localhost closed. START DONE!
  13. % ./edeliver build upgrade --from=1.2.0 Using local release store. BUILDING

    UPGRADE OF BOLDPOKER_GAME APP ON BUILD HOST -----> Authorizing hosts -----> Validating * version 1.2.0 is in local release store -----> Ensuring hosts are ready to accept git pushes -----> Pushing new commits with git to: msch@localhost -----> Resetting remote hosts to 896d81a67 -----> Stashing build directory on remote build host -----> Checking out 896d81a676df3c477689d2c72c5562d5edcf1999 -----> Fetching / Updating dependencies -----> Compiling sources -----> Uploading archive of release 1.2.0 from local release store -----> Extracting archive boldpoker_game_1.2.0.tar.gz -----> Generating release -----> Copying release to local release store -----> Copying boldpoker_game-1.2.4.tar.gz to release store UPGRADE BUILD OF BOLDPOKER_GAME WAS SUCCESSFUL!
  14. % ./edeliver deploy upgrade to production Using local release store.

    DEPLOYING UPGRADE OF BOLDPOKER_GAME APP TO PRODUCTION HOSTS -----> Authorizing hosts -----> Uploading archive of release 1.2.4 from local release store -----> Upgrading release to 1.2.4 DEPLOYED UPGRADE TO PRODUCTION!