fix startup issue introduced when logs moved

This commit is contained in:
dovholuknf
2020-11-30 12:19:11 -05:00
parent e037677ac8
commit ea885cb911
3 changed files with 25 additions and 2 deletions
+15
View File
@@ -47,3 +47,18 @@ func LogsPath() string {
func BackupFile() string {
return File() + ".backup"
}
func EnsureConfigFolder() error {
return ensureFolder(Path())
}
func EnsureLogsFolder() error {
return ensureFolder(LogsPath())
}
func ensureFolder(path string) error {
if _, err := os.Stat(path); os.IsNotExist(err) {
mkdirerr := os.Mkdir(path, 0644)
if mkdirerr != nil {
return mkdirerr
}
}
return nil
}
+9 -1
View File
@@ -21,6 +21,7 @@ package service
import (
"fmt"
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/config"
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/util/logging"
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/debug"
@@ -30,7 +31,14 @@ type zitiService struct{}
func (m *zitiService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) {
changes <- svc.Status{State: svc.StartPending}
err := config.EnsureConfigFolder()
if err != nil {
log.Panic("config folder not found and was not created by process!")
}
err = config.EnsureLogsFolder()
if err != nil {
log.Panic("log folder not found and was not created by process!")
}
control := make(chan string)
mainLoop := make(chan struct{})
go func() {
+1 -1
View File
@@ -1 +1 @@
1.6.0
1.6.1