svc

package
v0.0.0-...-b347bf8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

提供运行程序的启动、停止的框架,标准化信号拦截的运行分块。 代码是简化了“github.com/judwhite/go-svc/svc“,不再提供windows服务的特殊处理,从而不再依赖"golang.org/x/sys/windows/svc"。 如果需要可以将应用程序替换回去。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(service Service) error

Run runs your Service.

Types

type Environment

type Environment interface {
	// IsWindowsService returns true if the program is running as a
	// Windows Service.
	IsWindowsService() bool
}

Environment interface contains information about the environment your application is running in.

type Service

type Service interface {
	// Init is called before the program/service is started and after it's
	// determined if the program is running as a Windows Service.
	Init(Environment) error
	// Start is called after Init. This method must be non-blocking.
	Start() error
	// Stop is called in response to os.Interrupt, os.Kill, or when a
	// Windows Service is stopped.
	Stop() error
}

Service interface contains Start and Stop methods which are called when the service is started and stopped. The Init method is called before the service is started, and after it's determined if the program is running as a Windows Service.

The Start method must be non-blocking.

Implement this interface and pass it to Run to start your program.

Jump to

Keyboard shortcuts

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