Documentation
¶
Overview ¶
Package service installs and controls Mihari as a native OS service.
Index ¶
- func IsInteractive() bool
- type Controller
- type Manager
- func (m *Manager) Install() error
- func (m *Manager) Reinstall() error
- func (m *Manager) Restart() error
- func (m *Manager) Run() error
- func (m *Manager) Start() error
- func (m *Manager) Status() (StatusKind, error)
- func (m *Manager) Stop() error
- func (m *Manager) Uninstall() error
- func (m *Manager) UpdateInstalledBinary() (bool, error)
- type Options
- type RunFunc
- type StatusKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInteractive ¶
func IsInteractive() bool
IsInteractive reports whether this process is running outside the OS service manager. When false (Windows service session), the daemon entrypoint must call Manager.Run so the process registers with SCM (StartServiceCtrlDispatcher).
Types ¶
type Controller ¶
type Controller interface {
Install() error
Uninstall() error
Start() error
Stop() error
Restart() error
Status() (StatusKind, error)
Run() error
}
Controller performs service manager operations (tests inject fakes).
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the production entry for service control.
func (*Manager) Install ¶
Install copies mihari into the machine install directory, then registers the OS service with that installed path (never the caller's download location).
func (*Manager) Reinstall ¶
Reinstall stops the service, removes registration, copies this binary into the install directory, re-registers ImagePath, and starts the service.
func (*Manager) Status ¶
func (m *Manager) Status() (StatusKind, error)
Status reports the service state. When the service is not registered, it returns StatusNotInstalled with a nil error so callers (CLI status, TUI badge) can distinguish "not installed" without elevation. On Windows, Access is denied from the default service library falls back to a low-privilege SCM query so non-admin users still see running/stopped/not_installed.
func (*Manager) Uninstall ¶
Uninstall stops the service (if running), then removes the OS service registration. Stopping first avoids Windows SCM "marked for deletion" while the process is still alive.
func (*Manager) UpdateInstalledBinary ¶ added in v0.7.0
UpdateInstalledBinary synchronizes the current executable into the machine install directory and restarts an existing OS service from that copy. It reports whether a service installation was found. A missing service is a successful no-op.
type Options ¶
type Options struct {
// Executable is the absolute path to mihari. Empty uses the current process executable.
Executable string
// Arguments defaults to ["daemon"].
Arguments []string
// Run is required only for Run().
Run RunFunc
// Ready is closed by the daemon body when the control plane is listening.
// When non-nil, program.Start waits for it (or run exit / timeout) before returning.
Ready <-chan struct{}
// StartTimeout bounds how long Start waits for Ready. Zero means 15s.
StartTimeout time.Duration
// NewController builds a Controller; tests replace it.
NewController func(run RunFunc, executable string, arguments []string) (Controller, error)
}
Options configures which binary the OS service should launch.
type StatusKind ¶
type StatusKind string
StatusKind is a redacted service state for CLI/JSON.
const ( StatusRunning StatusKind = "running" StatusStopped StatusKind = "stopped" StatusUnknown StatusKind = "unknown" StatusNotInstalled StatusKind = "not_installed" )