service

package
v0.0.0-...-1830482 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ServiceRunning = "running"
	ServiceFailed  = "failed"
	ServiceMissing = "missing"
	ServiceStop    = "stopped"
)

Variables

This section is empty.

Functions

func GetPackageVersion

func GetPackageVersion(service string) *string

GetPackageVersion return package version

func InstallPackages

func InstallPackages(services map[string]Service)

InstallPackages start all given services

func RemoveServices

func RemoveServices(services map[string]Service)

RemoveServices remove all given services

func StartServices

func StartServices(services map[string]Service)

StartServices start all given services

func WriteServiceConfig

func WriteServiceConfig(path string, config ServiceConfig) error

WriteServiceConfig store configuration

Types

type APIInfo

type APIInfo struct {
	CertPath       string `json:"certPath"`
	KeyPath        string `json:"keyPath"`
	Password       string `json:"password"`
	IP             string `json:"ip"`
	Port           string `json:"port"`
	URLToken       string `json:"urlToken"`
	BrowsingFolder string `json:"browsingFolder"`
	APIVersion     string `json:"apiVersion"`
}

APIInfo api description

type Broker

type Broker struct {
	IP       string `json:"ip"`
	Port     string `json:"port"`
	Login    string `json:"login"`
	Password string `json:"password"`
	CaPath   string `json:"caPath"`
	Secure   bool   `json:"secure"`
}

Broker description

type DBConnector

type DBConnector struct {
	ClientIP   string `json:"clientIp"`
	ClientPort string `json:"clientPort"`
}

DBConnector description

type IService

type IService interface {
	Initialize(confFile string) error
	Stop()
	Run() error
}

IService definition

type Service

type Service struct {
	Name        string   `json:"name"`
	Systemd     []string `json:"systemd"` //systemd service
	Version     string   `json:"version"`
	PackageName string   `json:"packageName"` //DebianPackageName
	ConfigPath  string   `json:"configPath"`
}

Service description

func ToService

func ToService(val interface{}) (*Service, error)

ToService convert map interface to Service object

func (Service) GetServiceStatus

func (s Service) GetServiceStatus() string

GetServiceStatus return service status

func (Service) Install

func (s Service) Install() (string, error)

Install install a given service

func (Service) Remove

func (s Service) Remove() (string, error)

Remove a given service

func (Service) Start

func (s Service) Start() (string, error)

Start a given service

func (Service) Stop

func (s Service) Stop() (string, error)

Stop a given service

type ServiceConfig

type ServiceConfig struct {
	LocalBroker     Broker      `json:"localBroker"`
	NetworkBroker   Broker      `json:"networkBroker"`
	AuthBroker      Broker      `json:"authBroker"`
	DB              DBConnector `json:"db"`
	HistoryDB       DBConnector `json:"historyDb"`
	LogLevel        string      `json:"logLevel"`
	ExternalAPI     APIInfo     `json:"externalAPI"`
	InternalAPI     APIInfo     `json:"internalAPI"`
	ClientAPI       APIInfo     `json:"clientAPI"`
	DataPath        string      `json:"dataPath"`
	ServiceDataPath string      `json:"serviceDataPath"`
}

ServiceConfig description

func ReadServiceConfig

func ReadServiceConfig(path string) (*ServiceConfig, error)

ReadServiceConfig parse the configuration file

func (ServiceConfig) ToJSON

func (config ServiceConfig) ToJSON() (string, error)

ToJSON dump switch config struct

type ServiceStatus

type ServiceStatus struct {
	Service
	Status *string `json:"status"` //enable/running/disable etc.
}

ServiceStatus description

Jump to

Keyboard shortcuts

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