本文整理汇总了Golang中golang.org/x/sys/windows/svc/mgr.Service类的典型用法代码示例。如果您正苦于以下问题:Golang Service类的具体用法?Golang Service怎么用?Golang Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Service类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: stopWait
func (ws *windowsService) stopWait(s *mgr.Service) error {
// First stop the service. Then wait for the service to
// actually stop before starting it.
status, err := s.Control(svc.Stop)
if err != nil {
return err
}
timeDuration := time.Millisecond * 50
timeout := time.After(getStopTimeout() + (timeDuration * 2))
tick := time.NewTicker(timeDuration)
defer tick.Stop()
for status.State != svc.Stopped {
select {
case <-tick.C:
status, err = s.Query()
if err != nil {
return err
}
case <-timeout:
break
}
}
return nil
}
开发者ID:sdhjl2000,项目名称:service,代码行数:27,代码来源:service_windows.go
示例2: getState
func getState(t *testing.T, s *mgr.Service) svc.State {
status, err := s.Query()
if err != nil {
t.Fatalf("Query(%s) failed: %s", s.Name, err)
}
return status.State
}
开发者ID:Chengyumeng,项目名称:sys,代码行数:7,代码来源:svc_test.go
示例3: testConfig
func testConfig(t *testing.T, s *mgr.Service, should mgr.Config) mgr.Config {
is, err := s.Config()
if err != nil {
t.Fatalf("Config failed: %s", err)
}
if should.DisplayName != is.DisplayName {
t.Fatalf("config mismatch: DisplayName is %q, but should have %q", is.DisplayName, should.DisplayName)
}
if should.StartType != is.StartType {
t.Fatalf("config mismatch: StartType is %v, but should have %v", is.StartType, should.StartType)
}
if should.Description != is.Description {
t.Fatalf("config mismatch: Description is %q, but should have %q", is.Description, should.Description)
}
if depString(should.Dependencies) != depString(is.Dependencies) {
t.Fatalf("config mismatch: Dependencies is %v, but should have %v", is.Dependencies, should.Dependencies)
}
return is
}
开发者ID:Chengyumeng,项目名称:sys,代码行数:19,代码来源:mgr_test.go
示例4: remove
func remove(t *testing.T, s *mgr.Service) {
err := s.Delete()
if err != nil {
t.Fatalf("Delete failed: %s", err)
}
}
开发者ID:Chengyumeng,项目名称:sys,代码行数:6,代码来源:mgr_test.go
注:本文中的golang.org/x/sys/windows/svc/mgr.Service类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论