2019-09-13 21:33:14 -07:00
|
|
|
// Package runtime is a service runtime manager
|
|
|
|
package runtime
|
|
|
|
|
|
|
|
// Runtime is a service runtime manager
|
|
|
|
type Runtime interface {
|
|
|
|
// Registers a service
|
2019-09-13 21:58:03 -07:00
|
|
|
Create(*Service) error
|
|
|
|
// Remove a service
|
|
|
|
Delete(*Service) error
|
2019-09-13 21:33:14 -07:00
|
|
|
// starts the runtime
|
2019-09-13 21:58:03 -07:00
|
|
|
Start() error
|
2019-09-13 21:33:14 -07:00
|
|
|
// Shutdown the runtime
|
|
|
|
Stop() error
|
|
|
|
}
|
|
|
|
|
|
|
|
type Service struct {
|
|
|
|
// name of the service
|
|
|
|
Name string
|
|
|
|
// url location of source
|
|
|
|
Source string
|
|
|
|
// path to store source
|
|
|
|
Path string
|
|
|
|
// exec command
|
|
|
|
Exec string
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
DefaultRuntime = newRuntime()
|
|
|
|
)
|
|
|
|
|
2019-09-13 21:58:03 -07:00
|
|
|
func Create(s *Service) error {
|
|
|
|
return DefaultRuntime.Create(s)
|
2019-09-13 21:33:14 -07:00
|
|
|
}
|
|
|
|
|
2019-09-13 21:58:03 -07:00
|
|
|
func Delete(s *Service) error {
|
|
|
|
return DefaultRuntime.Delete(s)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Start() error {
|
|
|
|
return DefaultRuntime.Start()
|
2019-09-13 21:33:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func Stop() error {
|
|
|
|
return DefaultRuntime.Stop()
|
|
|
|
}
|