lujiajing1126 commented on a change in pull request #74:
URL: https://github.com/apache/skywalking-banyandb/pull/74#discussion_r794152963



##########
File path: banyand/prof/pprof.go
##########
@@ -0,0 +1,74 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package prof
+
+import (
+       "net/http"
+       // Register pprof package
+       _ "net/http/pprof"
+
+       "github.com/apache/skywalking-banyandb/pkg/logger"
+       "github.com/apache/skywalking-banyandb/pkg/run"
+)
+
+var (
+       _ run.Service = (*pprofService)(nil)
+       _ run.Config  = (*pprofService)(nil)
+)
+
+func NewProfService() run.Service {
+       return &pprofService{
+               stopCh: make(chan struct{}),
+       }
+}
+
+type pprofService struct {
+       listenAddr string
+       stopCh     chan struct{}
+       l          *logger.Logger
+}
+
+func (p *pprofService) FlagSet() *run.FlagSet {
+       flagSet := run.NewFlagSet("prof")
+       flagSet.StringVar(&p.listenAddr, "pprof-listener-addr", 
"127.0.0.1:6060", "listen addr for pprof")

Review comment:
       > Then where should be documented? I feel this kind of thing will be 
missed from time to time.
   
   Currently the flag system designed by @hanahmily is self-described,
   
   ```
   $ ./banyand/build/bin/banyand-server standalone --help
   2022-01-28T10:08:32+08:00 | DEBUG | ***register flags**** module:STANDALONE 
name:METADATA registered:1 total:4
   2022-01-28T10:08:32+08:00 | DEBUG | ***register flags**** module:STANDALONE 
name:STREAM registered:2 total:4
   2022-01-28T10:08:32+08:00 | DEBUG | ***register flags**** module:STANDALONE 
name:GRPC registered:3 total:4
   2022-01-28T10:08:32+08:00 | DEBUG | ***register flags**** module:STANDALONE 
name:PPROF-SERVICE registered:4 total:4
   Run as the standalone mode
   
   Usage:
      standalone [flags]
   
   Flags:
         --addr string                  The address of banyand listens (default 
":17912")
         --cert-file string             The TLS cert file
     -h, --help                         help for standalone
         --key-file string              The TLS key file
         --logging.env string           the logging (default "dev")
         --logging.level string         the level of logging (default "debug")
         --max-recv-msg-size int        The size of max receiving message 
(default 10485760)
         --metadata-root-path string    the root path of metadata (default 
"/tmp")
     -n, --name string                  name of this service (default 
"standalone")
         --pprof-listener-addr string   listen addr for pprof (default 
"127.0.0.1:6060")
         --root-path string             the root path of database (default 
"/tmp")
         --show-rungroup-units          show rungroup units
         --tls                          Connection uses TLS if true, else plain 
TCP
     -v, --version                      version for standalone
   ```
   
   all flags registered will be automatically shown in the help messages. I am 
not sure if this is what you want.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to