File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ import (
19
19
func main () {
20
20
ctx := common .GetContextWithLogger ()
21
21
22
+ root .PrintStackTraces ()
23
+
22
24
shouldTerminate , err := common .ContainerBackendProcessStartupHook ()
23
25
if err != nil {
24
26
common .TerminateWithError (err .Error (), 1 )
Original file line number Diff line number Diff line change 5
5
"fmt"
6
6
"os"
7
7
"path/filepath"
8
+ "runtime"
9
+ "strconv"
10
+ "time"
8
11
9
12
"github.com/spf13/cobra"
10
13
@@ -256,3 +259,27 @@ func SetupTelemetryInit(rootCmd *cobra.Command) {
256
259
}
257
260
}
258
261
}
262
+
263
+ func PrintStackTraces () {
264
+ if os .Getenv ("WERF_PRINT_STACK_TRACES" ) != "1" {
265
+ return
266
+ }
267
+
268
+ period := 5
269
+ if prd := os .Getenv ("WERF_PRINT_STACK_TRACES_PERIOD" ); prd != "" {
270
+ p , err := strconv .Atoi (prd )
271
+ if err == nil {
272
+ period = p
273
+ }
274
+ }
275
+
276
+ go func () {
277
+ for {
278
+ buf := make ([]byte , 1 << 16 )
279
+ runtime .Stack (buf , true )
280
+ fmt .Printf ("%s" , buf )
281
+
282
+ time .Sleep (time .Second * time .Duration (period ))
283
+ }
284
+ }()
285
+ }
You can’t perform that action at this time.
0 commit comments