PhoenixAssets.DevProcess (PhoenixAssets v0.1.0)

View Source

A declaration of an external development process to supervise (Vite, Storybook).

Plugins return these from PhoenixAssets.Plugin.dev_processes/2. The dev supervisor turns each declaration into a supervised child that MuonTrap tears down when the BEAM stops. Where MuonTrap can use Linux cgroups the whole OS process tree goes with it; on macOS (and other systems without cgroups) only the immediate child is killed, so a stubborn grandchild can still leak. The child-spec construction (to_child_spec/2) lives alongside the dev supervisor.

Summary

Functions

Builds a dev-process declaration from a keyword list or map of attributes.

Builds a supervised MuonTrap.Daemon child spec for this dev process.

Types

t()

@type t() :: %PhoenixAssets.DevProcess{
  cd: Path.t(),
  command: [String.t()],
  enabled: boolean(),
  env: [{String.t(), String.t()}],
  id: atom(),
  port: pos_integer() | nil,
  restart: :transient | :permanent | :temporary
}

Functions

new(attrs)

@spec new(Enumerable.t()) :: t()

Builds a dev-process declaration from a keyword list or map of attributes.

to_child_spec(process, opts \\ [])

@spec to_child_spec(
  t(),
  keyword()
) :: Supervisor.child_spec()

Builds a supervised MuonTrap.Daemon child spec for this dev process.

MuonTrap wraps the OS process and kills it when the BEAM exits -- even on a hard crash -- releasing the port (the whole process tree where Linux cgroups are available, otherwise the immediate child). stderr_to_stdout: true folds the process's stderr into stdout so Vite/Storybook errors reach the log buffer. :logger_fun (an mfargs tuple) routes that output to the dev server's log buffer. Each start emits [:phoenix_assets, :dev_server, :start], and the dev server monitors the daemon to emit :stop/:crash on exit.