server: Fix multihost crash

As introduced in v0.99.0.

Fixes #9901
This commit is contained in:
Bjørn Erik Pedersen
2022-05-18 09:47:55 +02:00
parent 3a8189ee93
commit 2f9eac480f
2 changed files with 56 additions and 21 deletions

View File

@@ -168,6 +168,14 @@ func (sc *serverCmd) server(cmd *cobra.Command, args []string) error {
c.Set("watch", true)
}
// TODO(bep) see issue 9901
// cfgInit is called twice, before and after the languages have been initialized.
// The servers (below) can not be initialized before we
// know if we're configured in a multihost setup.
if len(c.languages) == 0 {
return nil
}
// We can only do this once.
serverCfgInit.Do(func() {
c.serverPorts = make([]serverPortListener, 1)