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 ¶
const ( RoleHost = "host" RoleSignal = "signal" // DefaultSignalName is the service name of a rendezvous server. DefaultSignalName = "remohop-signal" )
Service roles.
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 ¶
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 )
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.