Docker-like process controls backed by pure systemd primitives.
unitctl is a small, opinionated layer over systemdkit. It starts isolated
transient services, then delegates lifecycle and inspection operations to
systemd over D-Bus. It does not shell out to systemctl and it does not use
Docker.
Example
{:ok, instance} =
Unitctl.start(
name: "demo-worker",
command: ["/usr/bin/env", "sleep", "60"],
description: "Demo worker",
resources: %{memory_max: 256 * 1024 * 1024, tasks_max: 64},
sandbox: %{no_new_privileges: true, private_tmp: true}
)
{:ok, state} = Unitctl.inspect(instance)
:ok = Unitctl.stop(instance)This package is intentionally higher-level than systemdkit: systemdkit
exposes systemd APIs; unitctl exposes runtime/app controls.
Summary
Functions
Reads common systemd state for an instance or unit name.
Restarts an instance or unit name.
Starts a transient systemd service from a Unitctl.Spec or keyword list.
Reads runtime stats for an instance or unit name.
Stops an instance or unit name.
Functions
@spec inspect( Unitctl.Instance.t() | String.t(), keyword() ) :: {:ok, Systemd.UnitState.t()} | {:error, term()}
Reads common systemd state for an instance or unit name.
@spec restart( Unitctl.Instance.t() | String.t(), keyword() ) :: :ok | {:ok, Systemd.Job.t()} | {:error, term()}
Restarts an instance or unit name.
@spec start(Unitctl.Spec.t() | keyword() | map()) :: {:ok, Unitctl.Instance.t()} | {:error, term()}
Starts a transient systemd service from a Unitctl.Spec or keyword list.
@spec stats( Unitctl.Instance.t() | String.t(), keyword() ) :: {:ok, Unitctl.Stats.t()} | {:error, term()}
Reads runtime stats for an instance or unit name.
Stats are sourced from systemd/cgroup D-Bus properties. Some fields may be
nil when the host systemd version does not expose the property or when the
corresponding accounting feature is disabled for the unit.
@spec stop( Unitctl.Instance.t() | String.t(), keyword() ) :: :ok | {:ok, Systemd.Job.t()} | {:error, term()}
Stops an instance or unit name.