mirror of
https://github.com/EnumeratedDev/enit.git
synced 2026-09-16 02:26:11 +00:00
Remove service dependencies field
This commit is contained in:
+4
-7
@@ -146,7 +146,6 @@ func Init() {
|
|||||||
service := EnitService{
|
service := EnitService{
|
||||||
Name: "",
|
Name: "",
|
||||||
Description: "",
|
Description: "",
|
||||||
Dependencies: make([]string, 0),
|
|
||||||
Type: "",
|
Type: "",
|
||||||
StartCmd: "",
|
StartCmd: "",
|
||||||
ExitMethod: "",
|
ExitMethod: "",
|
||||||
@@ -217,13 +216,11 @@ func Init() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(service.GetUnmetDependencies()) == 0 {
|
err := service.StartService()
|
||||||
err := service.StartService()
|
if err != nil {
|
||||||
if err != nil {
|
logger.Printf("Error: could not start service (%s): %s", service.Name, err)
|
||||||
logger.Printf("Error: could not start service (%s): %s", service.Name, err)
|
|
||||||
}
|
|
||||||
remainingServices--
|
|
||||||
}
|
}
|
||||||
|
remainingServices--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-32
@@ -38,18 +38,17 @@ var EnitServiceStateNames map[EnitServiceState]string = map[EnitServiceState]str
|
|||||||
}
|
}
|
||||||
|
|
||||||
type EnitService struct {
|
type EnitService struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Description string `yaml:"description,omitempty"`
|
Description string `yaml:"description,omitempty"`
|
||||||
Dependencies []string `yaml:"dependencies,omitempty"`
|
Type string `yaml:"type"`
|
||||||
Type string `yaml:"type"`
|
StartCmd string `yaml:"start_cmd"`
|
||||||
StartCmd string `yaml:"start_cmd"`
|
ExitMethod string `yaml:"exit_method"`
|
||||||
ExitMethod string `yaml:"exit_method"`
|
CrashOnSafeExit bool `yaml:"crash_on_safe_exit"`
|
||||||
CrashOnSafeExit bool `yaml:"crash_on_safe_exit"`
|
StopCmd string `yaml:"stop_cmd,omitempty"`
|
||||||
StopCmd string `yaml:"stop_cmd,omitempty"`
|
Restart string `yaml:"restart,omitempty"`
|
||||||
Restart string `yaml:"restart,omitempty"`
|
ReadyFd int `yaml:"ready_fd"`
|
||||||
ReadyFd int `yaml:"ready_fd"`
|
Setpgid bool `yaml:"setpgid"`
|
||||||
Setpgid bool `yaml:"setpgid"`
|
LogOutput bool `yaml:"log_output,omitempty"`
|
||||||
LogOutput bool `yaml:"log_output,omitempty"`
|
|
||||||
Filepath string
|
Filepath string
|
||||||
filepathChecksum [32]byte
|
filepathChecksum [32]byte
|
||||||
state EnitServiceState
|
state EnitServiceState
|
||||||
@@ -62,25 +61,6 @@ type EnitService struct {
|
|||||||
var Services = make([]*EnitService, 0)
|
var Services = make([]*EnitService, 0)
|
||||||
var startedServicesOrder = make([]string, 0)
|
var startedServicesOrder = make([]string, 0)
|
||||||
|
|
||||||
func (service *EnitService) GetUnmetDependencies() (missingDependencies []string) {
|
|
||||||
for _, dependency := range service.Dependencies {
|
|
||||||
if strings.HasPrefix(dependency, "/") {
|
|
||||||
// File dependency
|
|
||||||
if _, err := os.Stat(dependency); err != nil {
|
|
||||||
missingDependencies = append(missingDependencies, dependency)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Service dependency
|
|
||||||
depService := GetServiceByName(dependency)
|
|
||||||
if depService == nil {
|
|
||||||
missingDependencies = append(missingDependencies, dependency)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return missingDependencies
|
|
||||||
}
|
|
||||||
|
|
||||||
func (service *EnitService) GetProcess() *os.Process {
|
func (service *EnitService) GetProcess() *os.Process {
|
||||||
process, _ := os.FindProcess(service.processID)
|
process, _ := os.FindProcess(service.processID)
|
||||||
|
|
||||||
@@ -151,7 +131,6 @@ func (service *EnitService) ReloadService() {
|
|||||||
newService := EnitService{
|
newService := EnitService{
|
||||||
Name: "",
|
Name: "",
|
||||||
Description: "",
|
Description: "",
|
||||||
Dependencies: make([]string, 0),
|
|
||||||
Type: "",
|
Type: "",
|
||||||
StartCmd: "",
|
StartCmd: "",
|
||||||
ExitMethod: "",
|
ExitMethod: "",
|
||||||
|
|||||||
Reference in New Issue
Block a user