Skip to content

Commit 646e757

Browse files
committed
restart the stopped service upon timeout dump
1 parent a6a0277 commit 646e757

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/node/dump_snapshot/dump_snapshot.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,18 @@ func GetDumpSnapshotCmd() *cobra.Command {
118118

119119
defer execCleanup()
120120

121+
var stoppedService bool
121122
go func() {
122123
time.Sleep(maxDuration)
123124
utils.PrintlnStdErr("ERR: timeout")
124125
execCleanup()
126+
if stoppedService {
127+
fmt.Println("INF: restarting service before exit due to timeout")
128+
ec := utils.LaunchApp("sudo", []string{"systemctl", "restart", serviceName})
129+
if ec != 0 {
130+
utils.PrintlnStdErr("ERR: failed to restart service", serviceName)
131+
}
132+
}
125133
os.Exit(1)
126134
}()
127135

@@ -181,6 +189,7 @@ func GetDumpSnapshotCmd() *cobra.Command {
181189
return
182190
}
183191
time.Sleep(15 * time.Second) // wait completely shutdown
192+
stoppedService = true
184193
}
185194

186195
fmt.Println("INF: exporting snapshot")

0 commit comments

Comments
 (0)