Unitctl.Spec (unitctl v0.1.0)

Copy Markdown View Source

Runtime specification for a systemd-backed process.

Unitctl.Spec is intentionally application-shaped instead of D-Bus-shaped. It describes what to run, while unitctl translates it to a transient systemd service through systemdkit.

Summary

Functions

Builds a runtime spec from a map or keyword list.

Builds a runtime spec or raises ArgumentError.

Converts the spec to typed systemdkit transient-unit properties.

Returns the transient systemd service unit name.

Types

resources()

@type resources() :: %{
  optional(:memory_max) => non_neg_integer(),
  optional(:tasks_max) => non_neg_integer(),
  optional(:cpu_quota) => non_neg_integer()
}

sandbox()

@type sandbox() :: %{
  optional(:dynamic_user) => boolean(),
  optional(:no_new_privileges) => boolean(),
  optional(:private_tmp) => boolean(),
  optional(:private_devices) => boolean(),
  optional(:protect_system) => String.t(),
  optional(:protect_home) => String.t()
}

t()

@type t() :: %Unitctl.Spec{
  bus: Systemd.DBus.bus(),
  command: [String.t()],
  description: String.t() | nil,
  environment: %{optional(String.t()) => String.t()},
  group: String.t() | nil,
  name: String.t(),
  resources: resources(),
  restart: String.t() | nil,
  sandbox: sandbox(),
  timeout_stop_usec: non_neg_integer() | nil,
  user: String.t() | nil,
  wait: boolean(),
  wait_timeout: non_neg_integer(),
  working_directory: String.t() | nil
}

Functions

new(attrs)

@spec new(map() | keyword()) :: {:ok, t()} | {:error, term()}

Builds a runtime spec from a map or keyword list.

new!(attrs)

@spec new!(map() | keyword()) :: t()

Builds a runtime spec or raises ArgumentError.

to_properties(spec)

@spec to_properties(t()) :: [Systemd.TransientUnit.Property.t()]

Converts the spec to typed systemdkit transient-unit properties.

unit_name(spec)

@spec unit_name(t()) :: String.t()

Returns the transient systemd service unit name.