Skip to content

Commit 98f9fca

Browse files
committed
add windows service restart
1 parent baaa07e commit 98f9fca

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

service_windows.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,30 @@ func (thisRef *windowsService) Install() error {
161161
},
162162
thisRef.serviceSpec.Args...,
163163
)
164+
165+
winService.SetRecoveryActions([]svcMgr.RecoveryAction{
166+
svcMgr.RecoveryAction{
167+
Type: svcMgr.ServiceRestart,
168+
Delay: time.Duration(thisRef.serviceSpec.Start.RestartTimeout) * time.Second,
169+
},
170+
svcMgr.RecoveryAction{
171+
Type: svcMgr.ServiceRestart,
172+
Delay: time.Duration(thisRef.serviceSpec.Start.RestartTimeout) * time.Second,
173+
},
174+
svcMgr.RecoveryAction{
175+
Type: svcMgr.ServiceRestart,
176+
Delay: time.Duration(thisRef.serviceSpec.Start.RestartTimeout) * time.Second,
177+
},
178+
svcMgr.RecoveryAction{
179+
Type: svcMgr.ServiceRestart,
180+
Delay: time.Duration(thisRef.serviceSpec.Start.RestartTimeout) * time.Second,
181+
},
182+
svcMgr.RecoveryAction{
183+
Type: svcMgr.ServiceRestart,
184+
Delay: time.Duration(thisRef.serviceSpec.Start.RestartTimeout) * time.Second,
185+
},
186+
}, 0)
187+
164188
if err != nil {
165189
if winService != nil {
166190
winService.Close()

0 commit comments

Comments
 (0)