github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/cmd/pyroscope/command/server.go (about)

     1  package command
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  
     6  	"github.com/pyroscope-io/pyroscope/pkg/cli"
     7  	"github.com/pyroscope-io/pyroscope/pkg/config"
     8  )
     9  
    10  func newServerCmd(cfg *config.Server) *cobra.Command {
    11  	vpr := newViper()
    12  	serverCmd := &cobra.Command{
    13  		Use:   "server [flags]",
    14  		Short: "Start pyroscope server. This is the database + web-based user interface",
    15  
    16  		DisableFlagParsing: true,
    17  		RunE: cli.CreateCmdRunFn(cfg, vpr, func(_ *cobra.Command, _ []string) error {
    18  			srv, err := cli.NewServer(cfg)
    19  			if err != nil {
    20  				return err
    21  			}
    22  			return srv.Start()
    23  		}),
    24  	}
    25  
    26  	cli.PopulateFlagSet(cfg, serverCmd.Flags(), vpr, cli.WithSkip("scrape-configs"))
    27  	_ = serverCmd.Flags().MarkHidden("metrics-export-rules")
    28  	return serverCmd
    29  }