mirror of
https://github.com/jkstack/libagent.git
synced 2025-12-24 12:11:57 +08:00
修正windows下未启动服务无法重启的问题
This commit is contained in:
7
agent.go
7
agent.go
@@ -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
52
agent_test.go
Normal 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{})
|
||||
}
|
||||
Reference in New Issue
Block a user