stdservice

package
v0.0.0-...-4d7095b Latest Latest
Warning

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

Go to latest
Published: May 2, 2016 License: Zlib Imports: 3 Imported by: 0

Documentation

Overview

Many services that run on different platforms cannot rely on flags to be passed for configuration. Some platforms require explicit install commands. This package handles the common boilerplate code. The following command may be passed to the executable as the first argument:

install | remove | run | start | stop

These commands will do the following actions:

install - Install the running executable as a service on the system.
remove - Remove the running executable as a service on the system.
run - Run the service as a command line application, output log to prompt.
start - Starts the service via system controls.
stop - Stops the service via system controls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(c *Config)

Depreciated. Same as *Config.Run().

Types

type Config

type Config struct {
	// Used to register the service with the operating system.
	Name, DisplayName, LongDescription string

	// Called when the service starts or stops.
	// Stop may be nil.
	Start, Stop func(c *Config)

	// Called after logging may be setup but before the service is started.
	// Init is optional and may be nil.
	// If Init returns an error, that error is logged to the logger
	// and the service start is aborted.
	// Init should not block.
	Init func(c *Config) error
	// contains filtered or unexported fields
}

Standard service configuration. Start MUST block. Stop MUST NOT block for more then a second or two.

func (*Config) Logger

func (c *Config) Logger() service.Logger

Get logger after Run() has been called.

func (*Config) Run

func (c *Config) Run()

Fill in configuration, then call Run() to setup basic handling. Blocks until program completes. Is intended to handle the standard simple cases for running a service.

func (*Config) Service

func (c *Config) Service() service.Service

Get service after Run() has been called.

type ConsoleLogger

type ConsoleLogger struct{}

func (ConsoleLogger) Error

func (ConsoleLogger) Error(format string, a ...interface{}) error

func (ConsoleLogger) Info

func (ConsoleLogger) Info(format string, a ...interface{}) error

func (ConsoleLogger) Warning

func (ConsoleLogger) Warning(format string, a ...interface{}) error

Jump to

Keyboard shortcuts

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