Store service state in struct

This commit is contained in:
2025-09-24 19:08:51 +03:00
parent 09d8b70009
commit 6d34559335
3 changed files with 12 additions and 53 deletions
+1 -12
View File
@@ -152,10 +152,10 @@ func Init() {
StopCmd: "",
Restart: "",
CrashOnSafeExit: true,
ServiceRunPath: "",
restartCount: 0,
stopChannel: make(chan bool),
LogOutput: true,
state: EnitServiceUnloaded,
}
if err := yaml.Unmarshal(bytes, &service); err != nil {
logger.Printf("Error: could not read service file %s", path.Join(serviceConfigDir, "services", entry.Name()))
@@ -188,17 +188,6 @@ func Init() {
service.Restart = "false"
}
service.ServiceRunPath = path.Join(runtimeServiceDir, service.Name)
err = os.MkdirAll(path.Join(service.ServiceRunPath), 0755)
if err != nil {
logger.Fatalf("Error: could not initialize ESVM: %s", err)
}
err = service.setCurrentState(EnitServiceUnloaded)
if err != nil {
logger.Fatalf("Error: could not initialize ESVM: %s", err)
}
Services = append(Services, &service)
logger.Printf("Service (%s) has been initialized!\n", service.Name)