Skip to content

About

Mishka Installer is a system plugin manager and run time pre-built library installer for Elixir

Topics

Resources

Security policy

Stars

42 stars

Watchers

1 watching

Forks

Repository files navigation

🧩 MishkaInstaller

A runtime plugin / event engine and pre-built library installer for Elixir. ✨

Hex.pm Hex Downloads CI License GitHub Sponsors Buy Me a Coffee


Warning

πŸ”§ Low maintenance. The author currently only responds to pull requests. Don't use master; the current release line is 0.1.17.


πŸ’­ Why?

Build apps whose features are activated as plugins at runtime β€” registration, SMS, social login β€” without touching the core source. Each feature becomes an event; anyone can attach plugins to it from outside your app.


✨ Features

  • πŸ”Œ Events & Hooks β€” register plugins for an event; they run in priority + dependency order.
  • ⚑ Fast dispatch β€” each event compiles to a module, so Hook.call/3 is a direct call: no GenServer, no DB on the read path.
  • 🩺 Health checks β€” optional per-plugin health_check/0, inspected via Hook.event_health/1.
  • 🌐 Multi-node β€” the Mnesia-backed store joins & replicates across a cluster automatically.
  • πŸ“¦ Runtime installer β€” load pre-built ebin artifacts (local path, URL, or GitHub release). Works in a mix release.

πŸ”Œ Events & Hooks

Define a plugin for an event β€” it auto-registers and runs whenever the event is called:

defmodule RegisterEmailSender do
  use MishkaInstaller.Event.Hook, event: "after_success_login"

  @impl true
  def call(entries), do: {:reply, entries}
end
# tweak defaults
use MishkaInstaller.Event.Hook,
  event: "after_success_login",
  initial: %{depends: [SomeEvent], priority: 20}

Call every plugin registered for an event:

alias MishkaInstaller.Event.Hook

Hook.call("after_success_login", params)
Hook.call("after_success_login", params, private: keep_this)  # extra data, untouched by plugins
Hook.call("after_success_login", params, return: true)        # return the original input
Hook.call("after_success_login", params, cannot_run: :refused) # the answer while a plugin is not loaded
Hook.call("after_success_login", params, raised: :failed)       # the answer when a plugin raises

A plugin that raises stops the chain: the plugins after it do not run, the error is logged with its stacktrace, and the call answers raised:, or params without it.

To start a plugin automatically, add its module to your supervision tree:

children = [RegisterEmailSender, ...]

Or run an extension's plugins as one group with its own restart budget, so a crash storm of plugins stops only the group and the rest of your tree keeps running:

children = [{MishkaInstaller.Event.PluginSupervisor, name: MyApp.Plugins, plugins: [RegisterEmailSender, ...]}]

A plugin's process only drives its lifecycle; the event runs in the caller's process. When the process dies, its supervisor starts it again with its stored status, and the event keeps running the plugin meanwhile. unregister/0 ends the process for good.

Switch a plugin off and on again β€” stop/0 disables it, enable/0 is the only way back:

RegisterEmailSender.stop()    # :stopped β€” survives restarts, and holds whatever depends on it
RegisterEmailSender.enable()  # :restarted β€” releases what it was holding

Note

A plugin's depends always run before it (cycles are rejected at registration), and a plugin can return {:reply, :halt, state} to stop the rest of the chain. Disabling a plugin holds everything that depends on it, transitively and across events, and re-enabling it releases them β€” nothing keeps a list of dependents. A plugin an operator stopped is never re-enabled on its own. See MishkaInstaller.Event.Hook.

Run in Livebook


πŸ“¦ Installer

Load an already-compiled ebin at runtime β€” no source compilation, so it's release-safe:

alias MishkaInstaller.Installer.Installer

Installer.install(%{app: "demo", version: "0.1.0", type: :path,                  path: "/ext/demo-0.1.0"})
Installer.install(%{app: "demo", version: "0.1.0", type: :url,                   path: "https://.../demo-ebin.tar.gz"})
Installer.install(%{app: "demo", version: "0.1.0", type: :github_tag,            path: "owner/repo", tag: "0.1.0"})
Installer.install(%{app: "demo", version: "0.1.0", type: :github_latest_release, path: "owner/repo"})

Installer.uninstall(%{app: "demo", version: "0.1.0"})

Note

version: must be a semantic version (MAJOR.MINOR.PATCH, with optional pre-release and build, e.g. 1.0.0-rc.1). Anything else, such as "1.0", is refused with an {:error, [...]} before anything is installed.

Note

Remote installs (:url/:github_*) are fail-closed: they require the source host/repo in config :mishka_installer, :allowlist, url_hosts:/github_repos:, a :url must be https, and a redirect is followed only to https hosts the install may use. checksum: (sha256) pins the artifact; without one a remote install logs a warning, and require_checksum: true in the same config refuses it; :protected_apps guards apps from being overwritten/removed. See MishkaInstaller.Installer.Installer.

Note

A downloaded archive is checked before anything is written: it is refused when it would unpack past max_bytes (default 500 MB), holds more than max_entries members (default 10 000), or holds a link, device or fifo. Set your own limits with config :mishka_installer, :archive_limits, max_bytes: ..., max_entries: .... See MishkaInstaller.Installer.LibraryHandler.extract/3.


🏭 Production deployment

An installed library is a pre-built ebin on disk plus a Mnesia record; on every boot it is replayed (put back on the code path and started). So both the ebins and the Mnesia data must live on a persistent (mounted) volume β€” otherwise installs do not survive a restart/redeploy. Point both at your volume (here /data):

# config/runtime.exs β€” /data is your mounted volume
config :mishka_installer,
  project_path: "/data",
  extensions_path: "/data/extensions"

config :mishka_installer, MishkaInstaller.MnesiaRepo,
  mnesia_dir: "/data/mnesia",
  essential: [MishkaInstaller.Event.Event, MishkaInstaller.Installer.Installer]

:extensions_path is where ebins are written; mnesia_dir is where the records live; :essential are the tables created on boot (the plugin and install stores β€” keep both). Just depend on :mishka_installer; its supervision tree starts automatically outside :test.

A real release restart proof lives in test/integration/production_release/ β€” run it with mix test --only production_release.


πŸš€ Installation

def deps do
  [{:mishka_installer, "~> 0.1.17"}]
end

Docs: hexdocs.pm/mishka_installer


πŸ’– Funding & sponsorship

MishkaInstaller is open-source software developed by Mishka Group. If your team or company benefits from it, please consider supporting continued development:

GitHub Sponsors Β Β Β  Buy Me a Coffee

β˜• Donate / sponsor: github.com/sponsors/mishka-group Β· buymeacoffee.com/mishkagroup

Thank you. πŸ’š


πŸ“œ License

Apache License 2.0 β€” see LICENSE.

Copyright Β© Mishka Group and contributors.

About

Mishka Installer is a system plugin manager and run time pre-built library installer for Elixir

Topics

Resources

Security policy

Stars

42 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages