commands: Revert the recent changes that allowed profiling on server rebuilds

There have been indications that this may freeze the server.
This commit is contained in:
Bjørn Erik Pedersen 2024-02-05 14:27:35 +01:00
parent 9c6d377872
commit c37bf19c89
No known key found for this signature in database
3 changed files with 13 additions and 15 deletions

View file

@ -339,11 +339,10 @@ func (r *rootCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args
if r.buildWatch { if r.buildWatch {
defer r.timeTrack(time.Now(), "Built") defer r.timeTrack(time.Now(), "Built")
} }
close, err := b.build() err := b.build()
if err != nil { if err != nil {
return err return err
} }
close()
return nil return nil
}() }()
if err != nil { if err != nil {

View file

@ -361,32 +361,34 @@ func (c *hugoBuilder) newWatcher(pollIntervalStr string, dirList ...string) (*wa
return watcher, nil return watcher, nil
} }
func (c *hugoBuilder) build() (func(), error) { func (c *hugoBuilder) build() error {
stopProfiling, err := c.initProfiling() stopProfiling, err := c.initProfiling()
if err != nil { if err != nil {
return nil, err return err
} }
defer func() {
if stopProfiling != nil {
stopProfiling()
}
}()
if err := c.fullBuild(false); err != nil { if err := c.fullBuild(false); err != nil {
return nil, err return err
} }
if !c.r.quiet { if !c.r.quiet {
c.r.Println() c.r.Println()
h, err := c.hugo() h, err := c.hugo()
if err != nil { if err != nil {
return nil, err return err
} }
h.PrintProcessingStats(os.Stdout) h.PrintProcessingStats(os.Stdout)
c.r.Println() c.r.Println()
} }
return func() { return nil
if stopProfiling != nil {
stopProfiling()
}
}, nil
} }
func (c *hugoBuilder) buildSites(noBuildLock bool) (err error) { func (c *hugoBuilder) buildSites(noBuildLock bool) (err error) {

View file

@ -495,19 +495,16 @@ func (c *serverCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, arg
} }
var close func()
err := func() error { err := func() error {
defer c.r.timeTrack(time.Now(), "Built") defer c.r.timeTrack(time.Now(), "Built")
var err error var err error
close, err = c.build() err = c.build()
return err return err
}() }()
if err != nil { if err != nil {
return err return err
} }
defer close()
return c.serve() return c.serve()
} }