Skip to content

Commit 201310a

Browse files
committed
build issues
1 parent ac7795c commit 201310a

File tree

3 files changed

+98
-30
lines changed

3 files changed

+98
-30
lines changed

rest/server_context.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -220,36 +220,6 @@ func NewServerContext(ctx context.Context, config *StartupConfig, persistentConf
220220
return sc
221221
}
222222

223-
// registerSignalHandlerForStackTrace will register a signal handler to capture stack traces
224-
// - SIGUSR1 causes Sync Gateway to record a stack trace of all running goroutines.
225-
func (sc *ServerContext) registerSignalHandlerForStackTrace(ctx context.Context) {
226-
signalChannel := make(chan os.Signal, 1)
227-
signal.Notify(signalChannel, syscall.SIGUSR1)
228-
229-
defer func() {
230-
signal.Stop(signalChannel)
231-
close(signalChannel)
232-
}()
233-
234-
go func() {
235-
select {
236-
case sig := <-signalChannel:
237-
base.InfofCtx(ctx, base.KeyAll, "Handling signal: %v", sig)
238-
switch sig {
239-
case syscall.SIGUSR1:
240-
// stack trace signal received
241-
currentTime := time.Now()
242-
timestamp := currentTime.Format(time.RFC3339)
243-
sc.logStackTraces(ctx, timestamp)
244-
default:
245-
// unhandled signal here
246-
}
247-
case <-ctx.Done():
248-
return
249-
}
250-
}()
251-
}
252-
253223
func (sc *ServerContext) WaitForRESTAPIs(ctx context.Context) error {
254224
timeout := 30 * time.Second
255225
interval := time.Millisecond * 100

rest/stack_trace_handler_uinx.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//go:build !windows
2+
// +build !windows
3+
4+
/*
5+
Copyright 2025-Present Couchbase, Inc.
6+
7+
Use of this software is governed by the Business Source License included in
8+
the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that
9+
file, in accordance with the Business Source License, use of this software will
10+
be governed by the Apache License, Version 2.0, included in the file
11+
licenses/APL2.txt.
12+
*/
13+
14+
package rest
15+
16+
import (
17+
"context"
18+
"os"
19+
"os/signal"
20+
"syscall"
21+
"time"
22+
23+
"github.com/couchbase/sync_gateway/base"
24+
)
25+
26+
// registerSignalHandlerForStackTrace will register a signal handler to capture stack traces
27+
// - SIGUSR1 causes Sync Gateway to record a stack trace of all running goroutines.
28+
func (sc *ServerContext) registerSignalHandlerForStackTrace(ctx context.Context) {
29+
signalChannel := make(chan os.Signal, 1)
30+
signal.Notify(signalChannel, syscall.SIGUSR1)
31+
32+
defer func() {
33+
signal.Stop(signalChannel)
34+
close(signalChannel)
35+
}()
36+
37+
go func() {
38+
select {
39+
case sig := <-signalChannel:
40+
base.InfofCtx(ctx, base.KeyAll, "Handling signal: %v", sig)
41+
switch sig {
42+
case syscall.SIGUSR1:
43+
// stack trace signal received
44+
currentTime := time.Now()
45+
timestamp := currentTime.Format(time.RFC3339)
46+
sc.logStackTraces(ctx, timestamp)
47+
default:
48+
// unhandled signal here
49+
}
50+
case <-ctx.Done():
51+
return
52+
}
53+
}()
54+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//go:build windows
2+
// +build windows
3+
4+
/*
5+
Copyright 2025-Present Couchbase, Inc.
6+
7+
Use of this software is governed by the Business Source License included in
8+
the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that
9+
file, in accordance with the Business Source License, use of this software will
10+
be governed by the Apache License, Version 2.0, included in the file
11+
licenses/APL2.txt.
12+
*/
13+
14+
package rest
15+
16+
// registerSignalHandlerForStackTrace will register a signal handler to capture stack traces
17+
// - SIGUSR1 causes Sync Gateway to record a stack trace of all running goroutines.
18+
func (sc *ServerContext) registerSignalHandlerForStackTrace(ctx context.Context) {
19+
signalChannel := make(chan os.Signal, 1)
20+
signal.Notify(signalChannel, syscall.SIGUSR1)
21+
22+
defer func() {
23+
signal.Stop(signalChannel)
24+
close(signalChannel)
25+
}()
26+
27+
go func() {
28+
select {
29+
case sig := <-signalChannel:
30+
base.InfofCtx(ctx, base.KeyAll, "Handling signal: %v", sig)
31+
switch sig {
32+
case syscall.SIGUSR1:
33+
// stack trace signal received
34+
currentTime := time.Now()
35+
timestamp := currentTime.Format(time.RFC3339)
36+
sc.logStackTraces(ctx, timestamp)
37+
default:
38+
// unhandled signal here
39+
}
40+
case <-ctx.Done():
41+
return
42+
}
43+
}()
44+
}

0 commit comments

Comments
 (0)