Skip to content

Commit 245d5d3

Browse files
authored
[+] add pprof build profile for debugging (#779)
1 parent 282fd57 commit 245d5d3

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

cmd/pgwatch/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ var Exit = os.Exit
4444

4545
func main() {
4646

47-
// Uncomment the following lines to enable the pprof HTTP server for debugging
48-
// go func() {
49-
// panic(http.ListenAndServe(":6060", nil))
50-
// }()
51-
5247
exitCode.Store(cmdopts.ExitCodeOK)
5348
defer func() {
5449
if err := recover(); err != nil {

cmd/pgwatch/pprof.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//go:build pprof
2+
3+
package main
4+
5+
import (
6+
"net/http"
7+
8+
_ "net/http/pprof" // Import for pprof HTTP server
9+
)
10+
11+
func init() {
12+
// Start pprof HTTP server for debugging when build tag 'pprof' is enabled
13+
go func() {
14+
// Using panic here will cause the application to exit if pprof server fails to start
15+
// This is intentional behavior for debugging builds
16+
panic(http.ListenAndServe(":6060", nil))
17+
}()
18+
}

docker/compose.pgwatch.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ services:
1414
ports:
1515
- "8080:8080"
1616
- "9187:9187"
17+
# - "6060:6060" # Uncomment for profiling
1718
depends_on:
1819
postgres:
1920
condition: service_healthy

0 commit comments

Comments
 (0)