service

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package service installs `remohop host` as an operating-system service that starts at boot and is restarted when it fails: a systemd unit on Linux, a launchd job on macOS, and a Windows service on Windows. It backs the `remohop service` command.

Index

Constants

View Source
const (
	RoleHost   = "host"
	RoleSignal = "signal"
	// DefaultSignalName is the service name of a rendezvous server.
	DefaultSignalName = "remohop-signal"
)

Service roles.

View Source
const DefaultName = "remohop"

DefaultName is the service name when --name is not given. Platforms map it to their own convention (the Windows service is "RemoHop", the launchd label com.remohop.host).

Variables

View Source
var RunHost = func(ctx context.Context, args []string, log io.Writer) error {
	host := cli.Lookup("host")
	if host == nil {
		return fmt.Errorf("the host command is not linked into this binary")
	}
	env := &cli.Env{Stdout: log, Stderr: log, Stdin: eofReader{}}
	if code := host.Run(ctx, env, args); code != cli.ExitOK {
		return fmt.Errorf("host exited with status %d", code)
	}
	return nil
}

RunHost runs the host until ctx is cancelled and returns when it has shut down. args are the arguments of `remohop host` (without "host"); log receives what the host prints. The Windows service process calls it, because a service has no terminal to run `remohop host` in.

The default runs the registered "host" command, so no wiring is needed; it is a variable so the host package or a test can substitute its own entry point.

Functions

This section is empty.

Types

type Installed

type Installed struct {
	Backend   string
	Name      string
	Scope     Scope
	Path      string   // unit / plist file; empty on Windows
	ConfigDir string   // REMOHOP_CONFIG_DIR of the instance; empty = the user's default
	RunAs     string   // account the system service runs as, if not root
	Notes     []string // extra advice, e.g. about linger
}

Installed describes a completed install, for the instructions the CLI prints.

type Options

type Options struct {
	Scope  Scope
	Name   string // service name; empty means DefaultName
	Signal string // --signal for the host; empty: host default
	// NoSignal runs the host with --no-signal: reachable by address only.
	NoSignal bool
	// ConfigDir overrides the instance's REMOHOP_CONFIG_DIR; empty means the
	// scope's default (the user's own, or the system state directory).
	ConfigDir string
	RunAs     string // systemd system scope: run as this account instead of root
	Exe       string // binary to run; empty means this executable
	Linger    bool   // systemd user scope: also run `loginctl enable-linger`
	// Role is what the service runs: RoleHost (the default, `remohop host`)
	// or RoleSignal (`remohop signal`, a rendezvous server).
	Role string
	// SignalArgs are the `remohop signal` flags of a RoleSignal service,
	// apart from --data, which the service sets.
	SignalArgs []string
	// Unattended (Windows only) gives remote users of the service the
	// interactive console session, the sign-in screen, the lock screen
	// and UAC prompts included (internal/unattended). Off unless asked.
	Unattended bool
}

Options describe the service to create or manage.

type Scope

type Scope int

Scope says whose service this is.

const (
	// ScopeAuto picks the scope: system for root, user otherwise; for the
	// management commands, whichever one is installed.
	ScopeAuto Scope = iota
	// ScopeUser runs the host as the installing user, from that user's login
	// or boot (with linger on Linux).
	ScopeUser
	// ScopeSystem runs the host system-wide, started by the init system.
	ScopeSystem
)

func (Scope) String

func (s Scope) String() string

type Status

type Status struct {
	Backend   string `json:"backend"`
	Name      string `json:"name"`
	Scope     string `json:"scope,omitempty"`
	Installed bool   `json:"installed"`
	Enabled   bool   `json:"enabled"`
	Running   bool   `json:"running"`
	State     string `json:"state,omitempty"`
	PID       int    `json:"pid,omitempty"`
	Since     string `json:"since,omitempty"`
	Path      string `json:"path,omitempty"`
	ConfigDir string `json:"config_dir,omitempty"`
	// Unattended: a Windows service installed with --unattended.
	Unattended bool `json:"unattended,omitempty"`
	// Exe is the binary the service definition starts, when it could be
	// read; ExeMissing says that file does not exist (removed by an upgrade
	// or uninstall), so the service cannot start.
	Exe        string `json:"exe,omitempty"`
	ExeMissing bool   `json:"exe_missing,omitempty"`
}

Status is the state of the installed service.

Jump to

Keyboard shortcuts

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