mirror of
https://github.com/EnumeratedDev/enit.git
synced 2026-09-25 15:06:11 +00:00
Add 'reload' service subcommand to ectl
This commit is contained in:
+26
-13
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -143,19 +144,21 @@ func Init() {
|
||||
}
|
||||
|
||||
service := EnitService{
|
||||
Name: "",
|
||||
Description: "",
|
||||
Dependencies: make([]string, 0),
|
||||
Type: "",
|
||||
StartCmd: "",
|
||||
ExitMethod: "",
|
||||
StopCmd: "",
|
||||
Restart: "",
|
||||
CrashOnSafeExit: true,
|
||||
restartCount: 0,
|
||||
stopChannel: make(chan bool),
|
||||
LogOutput: true,
|
||||
state: EnitServiceUnloaded,
|
||||
Name: "",
|
||||
Description: "",
|
||||
Dependencies: make([]string, 0),
|
||||
Type: "",
|
||||
StartCmd: "",
|
||||
ExitMethod: "",
|
||||
StopCmd: "",
|
||||
Restart: "",
|
||||
CrashOnSafeExit: true,
|
||||
LogOutput: true,
|
||||
Filepath: path.Join(serviceConfigDir, "services", entry.Name()),
|
||||
filepathChecksum: sha256.Sum256(bytes),
|
||||
restartCount: 0,
|
||||
stopChannel: make(chan bool),
|
||||
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()))
|
||||
@@ -227,6 +230,16 @@ func Init() {
|
||||
logger.Println("ESVM initialized successfully!")
|
||||
}
|
||||
|
||||
func Reload() {
|
||||
logger.Println("Reloading all ESVM services...")
|
||||
|
||||
for _, service := range Services {
|
||||
service.ReloadService()
|
||||
}
|
||||
|
||||
logger.Println("All ESVM services have been reloaded!")
|
||||
}
|
||||
|
||||
func Destroy() {
|
||||
logger.Println("Stopping all ESVM services...")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user