Create control file if not exist
This commit is contained in:
parent
76689159fb
commit
fc38252492
11
main.go
11
main.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
|
@ -81,7 +82,15 @@ func runDaemon() {
|
|||
log.Printf(DAEMON_FILE_REFRESH, serviceFile)
|
||||
startup, err := readLines(serviceFile)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
test, err := os.Create(serviceFile)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
test.Close()
|
||||
} else {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
for _, svc := range startup {
|
||||
running := false
|
||||
|
|
Loading…
Reference in New Issue