service

package module
v0.0.0-...-c8acd75 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2014 License: Zlib Imports: 7 Imported by: 0

README

service will install / un-install, start / stop, and run a program as a service (daemon).
Currently supports Windows XP+, Linux/(systemd | Upstart | SysV), and OSX/Launchd.

To start out follow "example/main.go".

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

This section is empty.

Functions

func GetExePath

func GetExePath() (exePath string, err error)

Depreciated. Use osext.Executable instead. Returns the full path of the running executable as reported by the system. Includes the executable image name.

Types

type Config

type Config struct {
	Name, DisplayName, Description string

	UserName  string   // Run as username.
	Arguments []string // Run with arguments.

	DependsOn        []string // Other services that this depends on.
	WorkingDirectory string   // Service working directory.
	ChRoot           string
	UserService      bool // Install as a current user service.

	// System specific parameters.
	KV KeyValue
}

Alpha API. Do not yet use.

type Controller

type Controller interface {
	// Starts this service on the system.
	Start() error

	// Stops this service on the system.
	Stop() error
}

A service that implements ServiceController is able to start and stop itself.

type Installer

type Installer interface {
	// Installs this service on the system.  May return an
	// error if this service is already installed.
	Install() error

	// Removes this service from the system.  May return an
	// error if this service is not already installed.
	Remove() error
}

Simple install and remove commands.

type KeyValue

type KeyValue map[string]interface{}

type Logger

type Logger interface {
	// Basic log functions in the context of the service.
	Error(format string, a ...interface{}) error
	Warning(format string, a ...interface{}) error
	Info(format string, a ...interface{}) error
}

A service that implements ServiceLogger can perform simple system logging.

type Runner

type Runner interface {
	// Call quickly after initial entry point.  Does not return until
	// service is ready to stop.  onStart is called when the service is
	// starting, returning an error will fail to start the service.
	// If an error is returned from onStop, the service will still stop.
	// An error passed from onStart or onStop will be returned as
	// an error from Run.
	// Both callbacks should return quickly and not block.
	Run(onStart, onStop func() error) error
}

A Generic way to stop and start a service.

type Service

type Service interface {
	Installer
	Controller
	Runner
	Logger
}

Represents a generic way to interact with the system's service.

func NewService

func NewService(name, displayName, description string) (Service, error)

Creates a new service. name is the internal name and should not contain spaces. Display name is the pretty print name. The description is an arbitrary string used to describe the service.

func NewServiceConfig

func NewServiceConfig(c *Config) (Service, error)

Alpha API. Do not yet use.

Directories

Path Synopsis
A simple and consistent method to extract a configuration from a file.
A simple and consistent method to extract a configuration from a file.
Many services that run on different platforms cannot rely on flags to be passed for configuration.
Many services that run on different platforms cannot rely on flags to be passed for configuration.

Jump to

Keyboard shortcuts

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