pprof.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //go:build PSIPHON_RUN_PPROF
  2. // +build PSIPHON_RUN_PPROF
  3. /*
  4. * Copyright (c) 2018, Psiphon Inc.
  5. * All rights reserved.
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. package psiphon
  22. import (
  23. "net/http"
  24. _ "net/http/pprof"
  25. "sync"
  26. )
  27. var pprofRunOnce sync.Once
  28. func pprofRun() {
  29. pprofRunOnce.Do(func() {
  30. go func() {
  31. NoticeInfo("Running http://localhost:6060/debug/pprof/")
  32. NoticeInfo("pprofRun: %s", http.ListenAndServe("localhost:6060", nil))
  33. }()
  34. })
  35. }