service

package
v0.6.28 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceAppLogFile = `service_app_{date:20060102}.log` //按天分割日志
	ServiceLogFile    = `service.log`
)

Variables

View Source
var DefaultMaxRetries = 10
View Source
var DefaultRetryInterval = 60 //60s

Functions

func FileWriter

func FileWriter(file string) (io.WriteCloser, error)

func New

func New(cfg *Config, action string) error

New 以服务的方式启动nging 服务支持的操作有: nging service install -- 安装服务 nging service uninstall -- 卸载服务 nging service start -- 启动服务 nging service stop -- 停止服务 nging service restart -- 重启服务

func NewProgram

func NewProgram(cfg *Config) *program

func Run

func Run(options *Options, action string) error

func ServiceLogDir

func ServiceLogDir() string

func ValidServiceAction

func ValidServiceAction(action string) error

Types

type Config

type Config struct {
	service.Config

	Dir           string
	Exec          string
	Args          []string
	Env           []string
	MaxRetries    int
	RetryInterval int // 重试间隔(秒)

	OnExited       func() error `json:"-"`
	Stderr, Stdout io.Writer    `json:"-"`
	// contains filtered or unexported fields
}

Config is the runner app config structure.

func (*Config) CopyFromOptions

func (c *Config) CopyFromOptions(options *Options) *Config

func (*Config) DefaultOptions

func (c *Config) DefaultOptions() service.KeyValue

type Options

type Options struct {
	Name          string // Required name of the service. No spaces suggested.
	DisplayName   string // Display name, spaces allowed.
	Description   string // Long description of service.
	Options       map[string]interface{}
	MaxRetries    int // 最大重试次数
	RetryInterval int // 重试间隔(秒)
}

Jump to

Keyboard shortcuts

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