tidb dyn_pprof_unix 源码

  • 2022-09-19
  • 浏览 (504)

tidb dyn_pprof_unix 代码

文件路径:/br/pkg/utils/dyn_pprof_unix.go

//go:build linux || darwin || freebsd || unix

// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.

package utils

import (
	"os"
	"os/signal"
	"syscall"

	"github.com/pingcap/log"
	tidbutils "github.com/pingcap/tidb/util"
	"go.uber.org/zap"
)

const startPProfSignal = syscall.SIGUSR1

// StartDynamicPProfListener starts the listener that will enable pprof when received `startPProfSignal`.
func StartDynamicPProfListener(tls *tidbutils.TLS) {
	signalChan := make(chan os.Signal, 1)
	signal.Notify(signalChan, startPProfSignal)
	go func() {
		for sig := range signalChan {
			if sig == startPProfSignal {
				log.Info("signal received, starting pprof...", zap.Stringer("signal", sig))
				if err := StartPProfListener("0.0.0.0:0", tls); err != nil {
					log.Warn("failed to start pprof", zap.Error(err))
					return
				}
			}
		}
	}()
}

相关信息

tidb 源码目录

相关文章

tidb backoff 源码

tidb db 源码

tidb dyn_pprof_other 源码

tidb env 源码

tidb json 源码

tidb key 源码

tidb math 源码

tidb misc 源码

tidb permission 源码

tidb pprof 源码

0  赞