aboutsummaryrefslogtreecommitdiffhomepage
path: root/commands
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-04-20 15:36:54 +0200
committerBjørn Erik Pedersen <[email protected]>2024-05-01 10:52:40 +0200
commitc8e400b621ea7d44e522fb9bfa66d992ccb9ca84 (patch)
tree909a5000f582792756bf5b75fba13ef362a3cfe7 /commands
parent9dd687027f2b37bdb94d51fed403066b9f7b9a45 (diff)
downloadhugo-c8e400b621ea7d44e522fb9bfa66d992ccb9ca84.tar.gz
hugo-c8e400b621ea7d44e522fb9bfa66d992ccb9ca84.zip
commands: Print "Webserver is ..." right before "Total ..."
Also fix it so * It's not printed when running `hugo -w` * It'd printed for all kinds of rebuilds Fixes #12384
Diffstat (limited to 'commands')
-rw-r--r--commands/commandeer.go6
-rw-r--r--commands/hugobuilder.go16
2 files changed, 17 insertions, 5 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go
index 616a3c867..5d4f02a4d 100644
--- a/commands/commandeer.go
+++ b/commands/commandeer.go
@@ -327,12 +327,12 @@ func (r *rootCommand) Name() string {
}
func (r *rootCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args []string) error {
+ b := newHugoBuilder(r, nil)
+
if !r.buildWatch {
- defer r.timeTrack(time.Now(), "Total")
+ defer b.postBuild("Total", time.Now())
}
- b := newHugoBuilder(r, nil)
-
if err := b.loadConfig(cd, false); err != nil {
return err
}
diff --git a/commands/hugobuilder.go b/commands/hugobuilder.go
index f5bc73087..657048d48 100644
--- a/commands/hugobuilder.go
+++ b/commands/hugobuilder.go
@@ -75,9 +75,14 @@ type hugoBuilder struct {
errState hugoBuilderErrState
}
+var errConfigNotSet = errors.New("config not set")
+
func (c *hugoBuilder) withConfE(fn func(conf *commonConfig) error) error {
c.confmu.Lock()
defer c.confmu.Unlock()
+ if c.conf == nil {
+ return errConfigNotSet
+ }
return fn(c.conf)
}
@@ -585,7 +590,7 @@ func (c *hugoBuilder) fullRebuild(changeType string) {
time.Sleep(2 * time.Second)
}()
- defer c.r.timeTrack(time.Now(), "Rebuilt")
+ defer c.postBuild("Rebuilt", time.Now())
err := c.reloadConfig()
if err != nil {
@@ -855,7 +860,7 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher,
c.changeDetector.PrepareNew()
func() {
- defer c.r.timeTrack(time.Now(), "Total")
+ defer c.postBuild("Total", time.Now())
if err := c.rebuildSites(dynamicEvents); err != nil {
c.handleBuildErr(err, "Rebuild failed")
}
@@ -901,6 +906,13 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher,
}
}
+func (c *hugoBuilder) postBuild(what string, start time.Time) {
+ if h, err := c.hugo(); err == nil && h.Conf.Running() {
+ h.LogServerAddresses()
+ }
+ c.r.timeTrack(start, what)
+}
+
func (c *hugoBuilder) hugo() (*hugolib.HugoSites, error) {
var h *hugolib.HugoSites
if err := c.withConfE(func(conf *commonConfig) error {