-
Notifications
You must be signed in to change notification settings - Fork 2
/
service.go
54 lines (45 loc) · 1.24 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package service
import (
spec "github.com/codemodify/systemkit-service-spec"
)
// Installer - installs and removes a service
type Installer interface {
Install() error
Uninstall() error
}
// Controller - starts and stops a service
type Controller interface {
Start() error
Stop() error
}
// Describer - gets info about a service
type Describer interface {
Info() Info
}
// Service -
type Service interface {
Installer
Controller
Describer
}
// NewServiceFromSERVICE -
func NewServiceFromSERVICE(serviceSpec spec.SERVICE) Service {
return newServiceFromSERVICE(serviceSpec)
}
// NewServiceFromName -
func NewServiceFromName(name string) (Service, error) {
return newServiceFromName(name)
}
// NewServiceFromPlatformTemplate -
func NewServiceFromPlatformTemplate(name string, template string) (Service, error) {
return newServiceFromPlatformTemplate(name, template)
}
// Info -
type Info struct {
Error error `json:"-"`
Service spec.SERVICE `json:"config,omitempty"`
IsRunning bool `json:"isRunning"`
PID int `json:"pid,omitempty"`
FilePath string `json:"filePath,omitempty"`
FileContent string `json:"fileContent,omitempty"`
}