Skip to content

Commit

Permalink
commands: Print "Webserver is ..." right before "Total ..."
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Apr 20, 2024
1 parent 004b694 commit 3d8cfc1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions commands/commandeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(time.Now())
}

b := newHugoBuilder(r, nil)

if err := b.loadConfig(cd, false); err != nil {
return err
}
Expand Down
9 changes: 8 additions & 1 deletion commands/hugobuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher,
c.changeDetector.PrepareNew()

func() {
defer c.r.timeTrack(time.Now(), "Total")
defer c.postBuild(time.Now())
if err := c.rebuildSites(dynamicEvents); err != nil {
c.handleBuildErr(err, "Rebuild failed")
}
Expand Down Expand Up @@ -901,6 +901,13 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher,
}
}

func (c *hugoBuilder) postBuild(start time.Time) {
if h, err := c.hugo(); err == nil && h.Conf.Running() {
h.LogServerAddresses()
}
c.r.timeTrack(start, "Total")
}

func (c *hugoBuilder) hugo() (*hugolib.HugoSites, error) {
var h *hugolib.HugoSites
if err := c.withConfE(func(conf *commonConfig) error {
Expand Down
4 changes: 1 addition & 3 deletions hugolib/hugo_sites_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -951,12 +951,10 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf
}
}

h.logServerAddresses()

return nil
}

func (h *HugoSites) logServerAddresses() {
func (h *HugoSites) LogServerAddresses() {
if h.hugoInfo.IsMultihost() {
for _, s := range h.Sites {
h.Log.Printf("Web Server is available at %s (bind address %s) %s\n", s.conf.C.BaseURL, s.conf.C.ServerInterface, s.Language().Lang)
Expand Down

0 comments on commit 3d8cfc1

Please sign in to comment.