Skip to content

Commit 1244fbd

Browse files
committed
restart service before exit if error occurs
1 parent 5337c70 commit 1244fbd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cmd/node/dump_snapshot/dump_snapshot.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ func GetDumpSnapshotCmd() *cobra.Command {
119119
defer execCleanup()
120120

121121
var stoppedService bool
122+
123+
defer func() {
124+
if exitWithError && stoppedService {
125+
fmt.Println("INF: restarting service before exit due to error")
126+
ec := utils.LaunchApp("sudo", []string{"systemctl", "restart", serviceName})
127+
if ec != 0 {
128+
utils.PrintlnStdErr("ERR: failed to restart service", serviceName)
129+
}
130+
}
131+
}()
132+
122133
go func() {
123134
time.Sleep(maxDuration)
124135
utils.PrintlnStdErr("ERR: timeout")

0 commit comments

Comments
 (0)