LemonCore. Runtime. Env
(lemon_core v0.1.0)
View Source
Environment resolution for Lemon runtime startup.
Centralises all the environment-variable defaults and path normalization that
previously lived in bin/lemon and bin/lemon-dev shell scripts.
Port defaults
| Port | Env var | Default |
|---|---|---|
| control | LEMON_CONTROL_PLANE_PORT | 4040 |
| web | LEMON_WEB_PORT | 4080 |
| sim | LEMON_SIM_UI_PORT | 4090 |
Usage
env = LemonCore.Runtime.Env.resolve()
env.control_port #=> 4040
env.web_port #=> 4080
env.lemon_root #=> "/path/to/lemon"
Summary
Functions
Applies resolved port values to the OTP application environment so running apps pick up the right port without restarts.
Returns the effective control-plane port.
Returns true when debug mode is enabled via LEMON_DEBUG or LEMON_LOG_LEVEL=debug.
Returns the Lemon project root directory.
Returns the Erlang distribution cookie.
Returns the Erlang node name to use (defaults to "lemon").
Validates that a production-grade cookie has been configured.
Resolves the runtime environment from system environment variables and defaults.
Returns the effective sim-ui port.
Returns the effective web port.
Types
@type t() :: %LemonCore.Runtime.Env{ control_port: pos_integer(), debug: boolean(), dotenv_dir: String.t() | nil, lemon_root: String.t() | nil, node_cookie: String.t() | nil, node_name: String.t(), sim_port: pos_integer(), web_port: pos_integer() }
Functions
@spec apply_ports(t()) :: :ok
Applies resolved port values to the OTP application environment so running apps pick up the right port without restarts.
Safe to call multiple times (idempotent).
@spec control_port() :: pos_integer()
Returns the effective control-plane port.
@spec debug?() :: boolean()
Returns true when debug mode is enabled via LEMON_DEBUG or LEMON_LOG_LEVEL=debug.
@spec lemon_root() :: String.t()
Returns the Lemon project root directory.
Reads LEMON_PATH if set; falls back to the directory two levels above
this file's location (i.e. the umbrella root when running from source).
@spec node_cookie() :: String.t() | nil
Returns the Erlang distribution cookie.
@spec node_name() :: String.t()
Returns the Erlang node name to use (defaults to "lemon").
@spec require_prod_cookie!() :: :ok
Validates that a production-grade cookie has been configured.
Raises RuntimeError if the cookie is the hardcoded dev default. Call this
from the boot sequence when running in a production context (e.g. when
RELEASE_NODE is set or MIX_ENV=prod).
@spec resolve() :: t()
Resolves the runtime environment from system environment variables and defaults.
@spec sim_port() :: pos_integer()
Returns the effective sim-ui port.
@spec web_port() :: pos_integer()
Returns the effective web port.