Documentation ¶
Overview ¶
Package service provides a simple way to create a system service. Currently supports Windows, Linux/(systemd | Upstart | SysV), and OSX/Launchd.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConsoleLogger = consoleLogger{}
ConsoleLogger logs to the std err.
Functions ¶
Types ¶
type Config ¶
type Config struct { Name string // Required name of the service. No spaces suggested. Privileged bool // If true, service will run as root/Administrator/etc Program string // The name of the program, defaults to the current program Arguments []string // Run with arguments. WorkingDirectory string // Optional, service working directory Start func() error // Required, function that starts the service (must not block) Stop func() error // Optional, function that gets called when the service is stopping }
Config provides the setup for a Service. The Name field is required.
type Service ¶
type Service interface { // Start signals to the OS service manager the given service should start. Start() error // Stop signals to the OS service manager the given service should stop. Stop() error // Restart signals to the OS service manager the given service should stop // then start. Restart() error // InstalLOrUpdateRequired checks whether the service needs to be installed // or udpated. InstallOrUpdateRequired() (bool, error) // InstallOrUpdate installs or updates the given service to the OS service manager. If // the service doesn't yet exist, it is created. If it already exists, the // existing service is updated. If additional privileges are needed, the // user is prompted with an escalation dialog. // // Returns true if the service was installed or updated, false if it was // left alone. InstallOrUpdate() (bool, error) // Uninstall uninstalls the given service from the OS service manager. This may require // greater rights. Will return an error if the service is not present. Uninstall() error // Run runs the service Run() error }
Service represents a service that can be run or controlled.
Directories ¶
Path | Synopsis |
---|---|
example
|
|
logging
Simple service that only works by printing a log message every few seconds.
|
Simple service that only works by printing a log message every few seconds. |
simple
simple does nothing except block while running the service.
|
simple does nothing except block while running the service. |
Click to show internal directories.
Click to hide internal directories.