Skip to content

Commit

Permalink
commands: Revert the recent changes that allowed profiling on server …
Browse files Browse the repository at this point in the history
…rebuilds

There have been indications that this may freeze the server.
  • Loading branch information
bep committed Feb 5, 2024
1 parent 9c6d377 commit c37bf19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
3 changes: 1 addition & 2 deletions commands/commandeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,10 @@ func (r *rootCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args
if r.buildWatch {
defer r.timeTrack(time.Now(), "Built")
}
close, err := b.build()
err := b.build()
if err != nil {
return err
}
close()
return nil
}()
if err != nil {
Expand Down
20 changes: 11 additions & 9 deletions commands/hugobuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,32 +361,34 @@ func (c *hugoBuilder) newWatcher(pollIntervalStr string, dirList ...string) (*wa
return watcher, nil
}

func (c *hugoBuilder) build() (func(), error) {
func (c *hugoBuilder) build() error {
stopProfiling, err := c.initProfiling()
if err != nil {
return nil, err
return err
}

defer func() {
if stopProfiling != nil {
stopProfiling()
}
}()

if err := c.fullBuild(false); err != nil {
return nil, err
return err
}

if !c.r.quiet {
c.r.Println()
h, err := c.hugo()
if err != nil {
return nil, err
return err
}

h.PrintProcessingStats(os.Stdout)
c.r.Println()
}

return func() {
if stopProfiling != nil {
stopProfiling()
}
}, nil
return nil
}

func (c *hugoBuilder) buildSites(noBuildLock bool) (err error) {
Expand Down
5 changes: 1 addition & 4 deletions commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,19 +495,16 @@ func (c *serverCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, arg

}

var close func()
err := func() error {
defer c.r.timeTrack(time.Now(), "Built")
var err error

Check failure on line 500 in commands/server.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

should merge variable declaration with assignment on next line (S1021)

Check failure on line 500 in commands/server.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

should merge variable declaration with assignment on next line (S1021)
close, err = c.build()
err = c.build()
return err
}()
if err != nil {
return err
}

defer close()

return c.serve()
}

Expand Down

0 comments on commit c37bf19

Please sign in to comment.