summaryrefslogtreecommitdiffstats
path: root/mattermost.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-11-22 11:05:54 -0800
committerHarrison Healey <harrisonmhealey@gmail.com>2016-11-22 14:05:54 -0500
commit7961599b2e41c71720a42b3bfde641f7529f05fe (patch)
tree3c039e1d3790a954ba65fe551c7b348331bce994 /mattermost.go
parente033dcce8e57ed6b6684227adf9b29347e4718b3 (diff)
downloadchat-7961599b2e41c71720a42b3bfde641f7529f05fe.tar.gz
chat-7961599b2e41c71720a42b3bfde641f7529f05fe.tar.bz2
chat-7961599b2e41c71720a42b3bfde641f7529f05fe.zip
PLT-4357 adding performance monitoring (#4622)
* WIP * WIP * Adding metrics collection * updating vendor packages * Adding metrics to config * Adding admin console page for perf monitoring * Updating glide * switching to tylerb/graceful
Diffstat (limited to 'mattermost.go')
-rw-r--r--mattermost.go67
1 files changed, 8 insertions, 59 deletions
diff --git a/mattermost.go b/mattermost.go
index 6a6455b9d..4a165ee55 100644
--- a/mattermost.go
+++ b/mattermost.go
@@ -14,7 +14,6 @@ import (
"os/exec"
"os/signal"
"runtime"
- "runtime/pprof"
"strconv"
"strings"
"syscall"
@@ -84,10 +83,6 @@ var flagChannelHeader string
var flagChannelPurpose string
var flagUserSetInactive bool
var flagImportArchive string
-var flagCpuProfile bool
-var flagMemProfile bool
-var flagBlockProfile bool
-var flagHttpProfiler bool
func doLoadConfig(filename string) (err string) {
defer func() {
@@ -127,26 +122,7 @@ func main() {
cmdUpdateDb30()
- if flagCpuProfile {
- f, err := os.Create(utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation) + ".cpu.prof")
- if err != nil {
- l4g.Error("Error creating cpu profile log: " + err.Error())
- }
-
- l4g.Info("CPU Profiler is logging to " + utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation) + ".cpu.prof")
- pprof.StartCPUProfile(f)
- }
-
- if flagBlockProfile {
- l4g.Info("Block Profiler is logging to " + utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation) + ".blk.prof")
- runtime.SetBlockProfileRate(1)
- }
-
- if flagMemProfile {
- l4g.Info("Memory Profiler is logging to " + utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation) + ".mem.prof")
- }
-
- api.NewServer(flagHttpProfiler)
+ api.NewServer()
api.InitApi()
web.InitWeb()
@@ -182,6 +158,10 @@ func main() {
einterfaces.GetClusterInterface().StartInterNodeCommunication()
}
+ if einterfaces.GetMetricsInterface() != nil {
+ einterfaces.GetMetricsInterface().StartServer()
+ }
+
// wait for kill signal before attempting to gracefully shutdown
// the running service
c := make(chan os.Signal)
@@ -192,38 +172,11 @@ func main() {
einterfaces.GetClusterInterface().StopInterNodeCommunication()
}
- api.StopServer()
-
- if flagCpuProfile {
- l4g.Info("Closing CPU Profiler")
- pprof.StopCPUProfile()
- }
-
- if flagBlockProfile {
- f, err := os.Create(utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation) + ".blk.prof")
- if err != nil {
- l4g.Error("Error creating block profile log: " + err.Error())
- }
-
- l4g.Info("Writing Block Profiler to: " + utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation) + ".blk.prof")
- pprof.Lookup("block").WriteTo(f, 0)
- f.Close()
- runtime.SetBlockProfileRate(0)
+ if einterfaces.GetMetricsInterface() != nil {
+ einterfaces.GetMetricsInterface().StopServer()
}
- if flagMemProfile {
- f, err := os.Create(utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation) + ".mem.prof")
- if err != nil {
- l4g.Error("Error creating memory profile file: " + err.Error())
- }
-
- l4g.Info("Writing Memory Profiler to: " + utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation) + ".mem.prof")
- runtime.GC()
- if err := pprof.WriteHeapProfile(f); err != nil {
- l4g.Error("Error creating memory profile: " + err.Error())
- }
- f.Close()
- }
+ api.StopServer()
}
}
@@ -435,10 +388,6 @@ func parseCmds() {
flag.BoolVar(&flagCmdActivateUser, "activate_user", false, "")
flag.BoolVar(&flagCmdSlackImport, "slack_import", false, "")
flag.BoolVar(&flagUserSetInactive, "inactive", false, "")
- flag.BoolVar(&flagCpuProfile, "cpuprofile", false, "")
- flag.BoolVar(&flagMemProfile, "memprofile", false, "")
- flag.BoolVar(&flagBlockProfile, "blkprofile", false, "")
- flag.BoolVar(&flagHttpProfiler, "httpprofiler", false, "")
flag.Parse()