修正windows下未启动服务无法重启的问题

This commit is contained in:
lwch
2022-12-09 10:12:52 +08:00
parent ca5444b050
commit 0ce0b44060
2 changed files with 59 additions and 0 deletions

View File

@@ -107,5 +107,12 @@ func Restart(app App) error {
if err != nil {
return err
}
status, err := svc.Status()
if err != nil {
return err
}
if status == service.StatusStopped {
return svc.Start()
}
return svc.Restart()
}

52
agent_test.go Normal file
View File

@@ -0,0 +1,52 @@
package agent
import (
"context"
"testing"
"github.com/jkstack/anet"
"github.com/jkstack/libagent/conf"
)
type agent struct{}
func (a *agent) AgentName() string {
return "example-agent"
}
func (a *agent) Version() string {
return "0.0.0"
}
func (a *agent) ConfDir() string {
return "./conf"
}
func (a *agent) Configure() *conf.Configure {
return &conf.Configure{}
}
func (a *agent) OnRewriteConfigure() error {
return nil
}
func (a *agent) OnConnect() {
}
func (a *agent) OnDisconnect() {
}
func (a *agent) OnReportMonitor() {
}
func (a *agent) OnMessage(*anet.Msg) error {
return nil
}
func (a *agent) LoopWrite(context.Context, chan *anet.Msg) error {
select {}
}
func TestRestart(t *testing.T) {
Restart(&agent{})
}