mirror of
https://github.com/Evidlo/remarkable_printer.git
synced 2024-10-19 19:17:37 -04:00
factor out restart-logic
This commit is contained in:
parent
ba1798ce46
commit
4a880b781d
28
main.go
28
main.go
|
@ -88,19 +88,8 @@ func main() {
|
|||
}
|
||||
handleRequest(conn)
|
||||
|
||||
// Restart xochitl
|
||||
if *restart {
|
||||
services := []string{"xochitl", "remux", "tarnish", "draft"}
|
||||
for _, service := range services {
|
||||
_, exitcode := exec.Command("systemctl", "is-active", service).CombinedOutput()
|
||||
if exitcode == nil {
|
||||
debug("Restarting " + service)
|
||||
stdout, err := exec.Command("systemctl", "restart", service).CombinedOutput()
|
||||
if err != nil {
|
||||
fmt.Println(service+" restart failed with message:", string(stdout))
|
||||
}
|
||||
}
|
||||
}
|
||||
restartUISoftware()
|
||||
}
|
||||
|
||||
if isSocketActivated {
|
||||
|
@ -198,3 +187,18 @@ func handleRequest(conn net.Conn) {
|
|||
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
// Restarts xochitl or other UI software
|
||||
func restartUISoftware() {
|
||||
services := []string{"xochitl", "remux", "tarnish", "draft"}
|
||||
for _, service := range services {
|
||||
_, exitcode := exec.Command("systemctl", "is-active", service).CombinedOutput()
|
||||
if exitcode == nil {
|
||||
debug("Restarting " + service)
|
||||
stdout, err := exec.Command("systemctl", "restart", service).CombinedOutput()
|
||||
if err != nil {
|
||||
fmt.Println(service+" restart failed with message:", string(stdout))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue