service

package
v0.2.46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package service provides cross-platform OS service management for Tela binaries (telad, telahubd). It handles install, uninstall, start, stop, and status operations using the native service manager on each OS (Windows SCM, systemd, launchd).

Each binary reads its runtime configuration from a YAML file in a well-known system directory. The service manager simply starts the binary with "service run", and the binary loads its config from the standard location. To reconfigure, edit the YAML and restart the service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryConfigPath

func BinaryConfigPath(binaryName string) string

BinaryConfigPath returns the standard path to a binary's YAML config file in the system-wide service config directory. e.g. "telad" → C:\ProgramData\Tela\telad.yaml (Windows)

"telad" → /etc/tela/telad.yaml             (Linux/macOS)

func ConfigDir

func ConfigDir() string

ConfigDir returns the directory where service configs are stored. Windows: %ProgramData%\Tela Linux: /etc/tela macOS: /etc/tela

func ConfigPath

func ConfigPath(binaryName string) string

ConfigPath returns the full path to the service config JSON file.

func Install

func Install(binaryName string, cfg *Config) error

Install creates a systemd unit file and enables the service.

func IsElevated

func IsElevated() bool

IsElevated returns true if the current process is running as root.

func IsWindowsService

func IsWindowsService() bool

IsWindowsService always returns false on Linux.

func RemoveConfig

func RemoveConfig(binaryName string) error

RemoveConfig deletes the service configuration file.

func RunAsService

func RunAsService(binaryName string, handler *Handler) error

RunAsService is a no-op on Linux (systemd manages the process lifecycle).

func SaveConfig

func SaveConfig(binaryName string, cfg *Config) error

SaveConfig writes the service configuration to disk.

func ServiceName

func ServiceName(binaryName string) string

ServiceName returns the OS service name for a given Tela binary. e.g., "telad" → "telad", "telahubd" → "telahubd"

func Start

func Start(binaryName string) error

Start starts the systemd service.

func Stop

func Stop(binaryName string) error

Stop stops the systemd service.

func Uninstall

func Uninstall(binaryName string) error

Uninstall stops, disables, and removes the systemd unit file.

Types

type Config

type Config struct {
	// BinaryPath is the absolute path to the executable.
	BinaryPath string `json:"binaryPath"`

	// Description is a human-readable service description.
	Description string `json:"description,omitempty"`

	// WorkingDir is the working directory for the service process.
	WorkingDir string `json:"workingDir,omitempty"`
}

Config holds the minimal metadata needed by the OS service manager. The actual runtime configuration (hub URLs, ports, etc.) lives in a YAML file that the binary reads on startup.

func LoadConfig

func LoadConfig(binaryName string) (*Config, error)

LoadConfig reads the service configuration from disk.

type Handler

type Handler struct {
	Run func(stopCh <-chan struct{})
}

Handler wraps a start/stop function pair (used on Windows; on Linux the process just runs normally and handles SIGTERM).

type Status

type Status struct {
	Installed bool
	Running   bool
	Info      string // platform-specific status detail
}

Status represents the current state of an installed service.

func QueryStatus

func QueryStatus(binaryName string) (*Status, error)

QueryStatus returns the current systemd service status.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL