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 ¶
- func BinaryConfigPath(binaryName string) string
- func ConfigDir() string
- func ConfigPath(binaryName string) string
- func Install(binaryName string, cfg *Config) error
- func IsElevated() bool
- func IsWindowsService() bool
- func RemoveConfig(binaryName string) error
- func RunAsService(binaryName string, handler *Handler) error
- func SaveConfig(binaryName string, cfg *Config) error
- func ServiceName(binaryName string) string
- func Start(binaryName string) error
- func Stop(binaryName string) error
- func Uninstall(binaryName string) error
- type Config
- type Handler
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinaryConfigPath ¶
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 ¶
ConfigPath returns the full path to the service config JSON file.
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 ¶
RemoveConfig deletes the service configuration file.
func RunAsService ¶
RunAsService is a no-op on Linux (systemd manages the process lifecycle).
func SaveConfig ¶
SaveConfig writes the service configuration to disk.
func ServiceName ¶
ServiceName returns the OS service name for a given Tela binary. e.g., "telad" → "telad", "telahubd" → "telahubd"
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 ¶
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 ¶
Status represents the current state of an installed service.
func QueryStatus ¶
QueryStatus returns the current systemd service status.