Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: fix profile port arg parsing #120

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions aperture.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ func (a *Aperture) Start(errChan chan error) error {
}

// Enable http profiling and validate profile port number if requested.
if a.cfg.ProfilePort != 0 {
if a.cfg.ProfilePort < 1024 || a.cfg.ProfilePort > 65535 {
if a.cfg.Profile != 0 {
if a.cfg.Profile < 1024 || a.cfg.Profile > 65535 {
return fmt.Errorf("the profile port must be between " +
"1024 and 65535")
}
Expand All @@ -212,9 +212,7 @@ func (a *Aperture) Start(errChan chan error) error {
"/debug/pprof", http.StatusSeeOther,
))

listenAddr := fmt.Sprintf(
"localhost:%d", a.cfg.ProfilePort,
)
listenAddr := fmt.Sprintf("localhost:%d", a.cfg.Profile)

log.Infof("Starting profile server at %s", listenAddr)
fmt.Println(http.ListenAndServe(listenAddr, nil))
Expand Down
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ type Config struct {
// BaseDir is a custom directory to store all aperture flies.
BaseDir string `long:"basedir" description:"Directory to place all of aperture's files in."`

// ProfilePort is the port on which the pprof profile will be served.
ProfilePort uint16 `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65535"`
// Profile is the port on which the pprof profile will be served.
Profile uint16 `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65535"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! interesting - TIL

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah a weird quirk with the YAML parser, I think we might've ran into this w/ the sqlite stuff too, but alas the wisdom was forgotten....

}

func (c *Config) validate() error {
Expand Down
Loading