Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

About

Elixir umbrella app showing hot upgrades with LiveView—no downtime, just smooth updates.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Myumbrella

Elixir umbrella applications can be smoothly hot-upgraded with DeployEx.

Running Locally

To start your Phoenix server:

  • Run mix setup to install and setup dependencies
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

Now you can visit localhost:4000 from your browser.

Genreating a hot-upgrade release

  1. Build the initial release (e.g., 0.1.0):
# Release the version 0.1.0
MIX_ENV=prod mix assets.deploy
MIX_ENV=prod mix release
  1. Update the version (e.g., from 0.1.0 to 0.1.1) in mix/shared.exs
  2. Build the new release with forced compilation:
MIX_ENV=prod mix assets.deploy
MIX_ENV=prod mix compile --force
MIX_ENV=prod mix release

Static Assets and Hot Upgrades

assets.deploy runs phx.digest, and cache_static_manifest is set in config/prod.exs, as deployex's hot-upgrades guide recommends. app_web/lib/app_web/application.ex already calls AppWebWeb.Endpoint.config_change/2 from config_change/3, which reloads the manifest on every hot upgrade, so a page opened before the upgrade keeps the digested files it loaded while a page rendered after it links to the new ones. Every release of this app must set "hot_upgrade_config_change": true in its current.json for that reload to happen. Plug.Static's gzip option is true in app_web_web/endpoint.ex to serve the pre-gzipped copies phx.digest produces. Build both the version you are upgrading from and the one you are upgrading to in the same _build directory without cleaning priv/static between them, so the release ships both sets of digested files.

Oban and Postgres

app_1 owns a Postgres-backed Ecto.Repo (App1.Repo) and an Oban instance, so a persisted job queue is available to poke at alongside app_1's and app_2's existing in-memory GenServer state. App1.Workers.PingWorker is a self-rescheduling job: each run inserts a row into hot_upgrade_pings and enqueues the next run a few seconds later, instead of using Oban.Plugins.Cron, so the chain is visible quickly while watching a hot upgrade. Because the job queue lives in Postgres rather than in the BEAM process, it is unaffected by a hot upgrade either way; SELECT count(*) FROM hot_upgrade_pings kept growing without a gap is the thing to check.

For local development, start Postgres with docker compose up -d, then run mix ecto.create && mix ecto.migrate (or eval App1.Migrator.create / eval App1.Migrator.migrate, the same pre-commands DeployEx's current.json runs before starting the release). In production, App1.Repo reads its connection from the DATABASE_URL environment variable (see config/runtime.exs).

Continuous Integration

Every pull request is checked by relup-guard-elixir, which builds the release at the PR's base and head commits and runs a real relup install between them. This catches hot-upgrade regressions before they merge. Since app_1's Repo and Oban are started on boot, the CI job also runs a Postgres service container and migrates it before relup-guard-elixir boots either release.

Observer Web Notes

If using Observer Web, install it in only one app (recommended: the LiveView web app).

About

Elixir umbrella app showing hot upgrades with LiveView—no downtime, just smooth updates.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages