This commit is contained in:
Rudi 2022-07-31 11:19:24 -04:00
parent 5f41341e1a
commit 1598980f0e
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
2 changed files with 18 additions and 21 deletions

15
main.go
View File

@ -3,7 +3,7 @@ package main
import (
"bufio"
"flag"
"fmt"
"fmt"
"log"
"os"
"os/exec"
@ -12,12 +12,12 @@ import (
)
var (
startup []string
daemon = false
startup []string
daemon = false
serviceFile = "/adm/services"
services = make(map[string]string)
controlSocket = "/adm/headless9/ctl/headless9.ctl"
logPath = "/adm/headless9/log/"
logPath = "/adm/headless9/log/"
)
func main() {
@ -45,7 +45,7 @@ func main() {
log.Println(err)
}
fmt.Println(strings.Join(sysTail(10, controlSocket), "\n"))
}
func getCtl() *os.File {
@ -119,12 +119,9 @@ func headlessControls() {
log.Printf(DAEMON_PROCESSING_CTL, cmd)
}
}
}
}
func execCommand(cmd string, arg ...string) {
defer PanicSafe()
if len(cmd) < 2 {
@ -210,4 +207,4 @@ func sysTail(count int, path string) []string {
lines := strings.Split(string(output), "\n")
return lines[:len(lines)-1]
}
}

View File

@ -1,16 +1,16 @@
package main
var (
DAEMON_START = "Starting headless9"
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_NOT_OPEN = "Unable to open 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 it's permissions are 700"
CTL_NOT_REWOUND = "Unable to rewind Control Socket. Please check the file %+v and that it's permissions are 700"
DAEMON_FILE_REFRESH = "Refreshing controlFile %+v"
DAEMON_SVC_EXISTS = "%+v exists as PID %+v"
DAEMON_SVC_MISSING = "Svc not detected, starting: %+v"
DAEMON_START = "Starting headless9"
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_NOT_OPEN = "Unable to open 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 it's permissions are 700"
CTL_NOT_REWOUND = "Unable to rewind Control Socket. Please check the file %+v and that it's permissions are 700"
DAEMON_FILE_REFRESH = "Refreshing controlFile %+v"
DAEMON_SVC_EXISTS = "%+v exists as PID %+v"
DAEMON_SVC_MISSING = "Svc not detected, starting: %+v"
DAEMON_PROCESSING_CTL = "Processing command: %+v"
DAEMON_CMD_INVALID = "Invalid command `%v`, skipping. Args: { %+v }"
DAEMON_SVC_FAIL = "Error starting service %+v, see log for more info."
)
DAEMON_CMD_INVALID = "Invalid command `%v`, skipping. Args: { %+v }"
DAEMON_SVC_FAIL = "Error starting service %+v, see log for more info."
)