Adjust service command outputs to use cmd Print functions

This commit is contained in:
mlsmaycon 2021-06-22 01:07:12 +02:00
parent 8088c7a591
commit a87f828844
2 changed files with 30 additions and 14 deletions

View File

@ -2,7 +2,6 @@ package cmd
import (
"github.com/kardianos/service"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@ -31,12 +30,15 @@ var (
s, err := newSVC(prg, newSVCConfig())
if err != nil {
log.Fatal(err)
cmd.PrintErrln(err)
return
}
err = s.Run()
if err != nil {
logger.Error(err) //nolint
cmd.PrintErrln(err)
return
}
cmd.Printf("Wiretrustee service is running")
},
}
)
@ -49,12 +51,15 @@ var (
s, err := newSVC(&program{}, newSVCConfig())
if err != nil {
log.Fatal(err)
cmd.PrintErrln(err)
return
}
err = s.Start()
if err != nil {
logger.Error(err) //nolint
cmd.PrintErrln(err)
return
}
cmd.Printf("Wiretrustee service has been started")
},
}
)
@ -67,12 +72,15 @@ var (
s, err := newSVC(&program{}, newSVCConfig())
if err != nil {
log.Fatal(err)
cmd.PrintErrln(err)
return
}
err = s.Stop()
if err != nil {
logger.Error(err) //nolint
cmd.PrintErrln(err)
return
}
cmd.Printf("Wiretrustee service has been stopped")
},
}
)
@ -85,12 +93,15 @@ var (
s, err := newSVC(&program{}, newSVCConfig())
if err != nil {
log.Fatal(err)
cmd.PrintErrln(err)
return
}
err = s.Restart()
if err != nil {
logger.Error(err) //nolint
cmd.PrintErrln(err)
return
}
cmd.Printf("Wiretrustee service has been restarted")
},
}
)

View File

@ -1,7 +1,6 @@
package cmd
import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"runtime"
)
@ -30,13 +29,16 @@ var (
s, err := newSVC(&program{}, svcConfig)
if err != nil {
log.Fatal(err)
cmd.PrintErrln(err)
return
}
err = s.Install()
if err != nil {
log.Error(err)
cmd.PrintErrln(err)
return
}
cmd.Printf("Wiretrustee service has been installed")
},
}
)
@ -49,13 +51,16 @@ var (
s, err := newSVC(&program{}, newSVCConfig())
if err != nil {
log.Fatal(err)
cmd.PrintErrln(err)
return
}
err = s.Uninstall()
if err != nil {
log.Error(err)
cmd.PrintErrln(err)
return
}
cmd.Printf("Wiretrustee has been uninstalled")
},
}
)