mirror of
https://github.com/kardianos/service.git
synced 2025-10-05 08:46:51 +08:00
Add documentation for platform options and expose to Godoc (#266)
This commit is contained in:
57
service.go
57
service.go
@@ -3,7 +3,7 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package service provides a simple way to create a system service.
|
// Package service provides a simple way to create a system service.
|
||||||
// Currently supports Windows, Linux/(systemd | Upstart | SysV), and OSX/Launchd.
|
// Currently supports Windows, Linux/(systemd | Upstart | SysV | OpenRC), and OSX/Launchd.
|
||||||
//
|
//
|
||||||
// Windows controls services by setting up callbacks that is non-trivial. This
|
// Windows controls services by setting up callbacks that is non-trivial. This
|
||||||
// is very different then other systems. This package provides the same API
|
// is very different then other systems. This package provides the same API
|
||||||
@@ -133,28 +133,6 @@ type Config struct {
|
|||||||
ChRoot string
|
ChRoot string
|
||||||
|
|
||||||
// System specific options.
|
// System specific options.
|
||||||
// * OS X
|
|
||||||
// - LaunchdConfig string () - Use custom launchd config
|
|
||||||
// - KeepAlive bool (true)
|
|
||||||
// - RunAtLoad bool (false)
|
|
||||||
// - UserService bool (false) - Install as a current user service.
|
|
||||||
// - SessionCreate bool (false) - Create a full user session.
|
|
||||||
// * POSIX
|
|
||||||
// - SystemdScript string () - Use custom systemd script
|
|
||||||
// - UpstartScript string () - Use custom upstart script
|
|
||||||
// - SysvScript string () - Use custom sysv script
|
|
||||||
// - RunWait func() (wait for SIGNAL) - Do not install signal but wait for this function to return.
|
|
||||||
// - ReloadSignal string () [USR1, ...] - Signal to send on reaload.
|
|
||||||
// - PIDFile string () [/run/prog.pid] - Location of the PID file.
|
|
||||||
// - LogOutput bool (false) - Redirect StdErr & StandardOutPath to files.
|
|
||||||
// - Restart string (always) - How shall service be restarted.
|
|
||||||
// - SuccessExitStatus string () - The list of exit status that shall be considered as successful,
|
|
||||||
// in addition to the default ones.
|
|
||||||
// * Linux (systemd)
|
|
||||||
// - LimitNOFILE int - Maximum open files (ulimit -n) (https://serverfault.com/questions/628610/increasing-nproc-for-processes-launched-by-systemd-on-centos-7)
|
|
||||||
// * Windows
|
|
||||||
// - DelayedAutoStart bool (false) - after booting start this service after some delay
|
|
||||||
|
|
||||||
Option KeyValue
|
Option KeyValue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +146,7 @@ var (
|
|||||||
ErrNameFieldRequired = errors.New("Config.Name field is required.")
|
ErrNameFieldRequired = errors.New("Config.Name field is required.")
|
||||||
// ErrNoServiceSystemDetected is returned when no system was detected.
|
// ErrNoServiceSystemDetected is returned when no system was detected.
|
||||||
ErrNoServiceSystemDetected = errors.New("No service system detected.")
|
ErrNoServiceSystemDetected = errors.New("No service system detected.")
|
||||||
// ErrNotInstalled is returned when the service is not installed
|
// ErrNotInstalled is returned when the service is not installed.
|
||||||
ErrNotInstalled = errors.New("the service is not installed")
|
ErrNotInstalled = errors.New("the service is not installed")
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -183,8 +161,35 @@ func New(i Interface, c *Config) (Service, error) {
|
|||||||
return system.New(i, c)
|
return system.New(i, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyValue provides a list of platform specific options. See platform docs for
|
// KeyValue provides a list of system specific options.
|
||||||
// more details.
|
// * OS X
|
||||||
|
// - LaunchdConfig string () - Use custom launchd config.
|
||||||
|
// - KeepAlive bool (true) - Prevent the system from stopping the service automatically.
|
||||||
|
// - RunAtLoad bool (false) - Run the service after its job has been loaded.
|
||||||
|
// - SessionCreate bool (false) - Create a full user session.
|
||||||
|
//
|
||||||
|
// * Solaris
|
||||||
|
// - Prefix string ("application") - Service FMRI prefix.
|
||||||
|
//
|
||||||
|
// * POSIX
|
||||||
|
// - UserService bool (false) - Install as a current user service.
|
||||||
|
// - SystemdScript string () - Use custom systemd script.
|
||||||
|
// - UpstartScript string () - Use custom upstart script.
|
||||||
|
// - SysvScript string () - Use custom sysv script.
|
||||||
|
// - OpenRCScript string () - Use custom OpenRC script.
|
||||||
|
// - RunWait func() (wait for SIGNAL) - Do not install signal but wait for this function to return.
|
||||||
|
// - ReloadSignal string () [USR1, ...] - Signal to send on reload.
|
||||||
|
// - PIDFile string () [/run/prog.pid] - Location of the PID file.
|
||||||
|
// - LogOutput bool (false) - Redirect StdErr & StandardOutPath to files.
|
||||||
|
// - Restart string (always) - How shall service be restarted.
|
||||||
|
// - SuccessExitStatus string () - The list of exit status that shall be considered as successful,
|
||||||
|
// in addition to the default ones.
|
||||||
|
// * Linux (systemd)
|
||||||
|
// - LimitNOFILE int (-1) - Maximum open files (ulimit -n)
|
||||||
|
// (https://serverfault.com/questions/628610/increasing-nproc-for-processes-launched-by-systemd-on-centos-7)
|
||||||
|
// * Windows
|
||||||
|
// - DelayedAutoStart bool (false) - After booting, start this service after some delay.
|
||||||
|
// - Password string () - Password to use when interfacing with the system service manager.
|
||||||
type KeyValue map[string]interface{}
|
type KeyValue map[string]interface{}
|
||||||
|
|
||||||
// bool returns the value of the given name, assuming the value is a boolean.
|
// bool returns the value of the given name, assuming the value is a boolean.
|
||||||
|
@@ -40,7 +40,7 @@ func versionCompare(v1, v2 []int) (int, error) {
|
|||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseVersion will parse any integer type version seperated by periods.
|
// parseVersion will parse any integer type version separated by periods.
|
||||||
// This does not fully support semver style versions.
|
// This does not fully support semver style versions.
|
||||||
func parseVersion(v string) []int {
|
func parseVersion(v string) []int {
|
||||||
version := make([]int, 3)
|
version := make([]int, 3)
|
||||||
|
Reference in New Issue
Block a user