This commit is contained in:
Rudi 2022-10-23 00:16:20 -04:00
parent ae99cfc014
commit aba9b67e9a
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
2 changed files with 15 additions and 15 deletions

22
main.go
View File

@ -144,17 +144,17 @@ func processCommand(cmd string) error {
start := time.Now() start := time.Now()
if verb == "restart" || verb == "stop" { if verb == "restart" || verb == "stop" {
f, err := os.OpenFile(fmt.Sprintf("/proc/%d/ctl", services[svc].ProcessHandle.Pid), os.O_WRONLY, 0660) f, err := os.OpenFile(fmt.Sprintf("/proc/%d/ctl", services[svc].ProcessHandle.Pid), os.O_WRONLY, 0660)
if err != nil { if err != nil {
log.Printf("") log.Printf("")
} }
defer f.Close() defer f.Close()
_, err = f.WriteString("kill") _, err = f.WriteString("kill")
if err != nil { if err != nil {
log.Printf(DAEMON_CTL_FAILED, err, time.Since(start)) log.Printf(DAEMON_CTL_FAILED, err, time.Since(start))
} else { } else {
delete(services, svc) delete(services, svc)
log.Printf(DAEMON_CTL_PROCESSED, svc, time.Since(start)) log.Printf(DAEMON_CTL_PROCESSED, svc, time.Since(start))
} }
} }
if verb == "restart" || verb == "start" { if verb == "restart" || verb == "start" {
startup, err := readLines(serviceFile) startup, err := readLines(serviceFile)

View File

@ -3,10 +3,10 @@ package main
var ( var (
DAEMON_START = "Starting headless9" DAEMON_START = "Starting headless9"
CMD_SYNTAX = "Command structure: \"headless9 $verb $service\"" CMD_SYNTAX = "Command structure: \"headless9 $verb $service\""
CTL_UNABLE_WRITE = "Unable to write to Control Socket. Please check the file %+v and that it's permissions are 700" CTL_UNABLE_WRITE = "Unable to write to Control Socket. Please check the file %+v and that it's permissions are 660"
CTL_NOT_OPEN = "Unable to open Control Socket. Please check the file %+v and that it's permissions are 700" CTL_NOT_OPEN = "Unable to open Control Socket. Please check the file %+v and that its permissions are 660"
CTL_NOT_CLEAR = "Unable to clear Control Socket. Please check the file %+v and that it's permissions are 700" CTL_NOT_CLEAR = "Unable to clear Control Socket. Please check the file %+v and that its permissions are 660"
CTL_NOT_REWOUND = "Unable to rewind Control Socket. Please check the file %+v and that it's permissions are 700" CTL_NOT_REWOUND = "Unable to rewind Control Socket. Please check the file %+v and that its permissions are 660"
DAEMON_FILE_REFRESH = "Refreshing controlFile %+v" DAEMON_FILE_REFRESH = "Refreshing controlFile %+v"
DAEMON_SVC_INVALID = "Invalid command `%v`, skipping. Args: { %+v }" DAEMON_SVC_INVALID = "Invalid command `%v`, skipping. Args: { %+v }"
DAEMON_SVC_DISABLED = "%+v is disabled, skipping!" DAEMON_SVC_DISABLED = "%+v is disabled, skipping!"