Skip to content

Commit e05244f

Browse files
committed
Run mDNS broadcast asynchronously
Run mDNS in a goroutine so the landing page server starts also in cases when the outbound IP address can't be determined or the mDNS server fails to start for another reason. This is easy to reproduce when the device has no network connectivity when it starts for the first time. In such case, the landing page errors with "connect: network is unreachable" and never starts after the cable is reconnected, leaving port 8123 unreachable until full Core is downloaded. Since mDNS is not mission-critical, we shouldn't block the webserver from starting and just start the mDNS asynchronously.
1 parent 9248f93 commit e05244f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ func main() {
4242
http.Handle("/frontend_latest/", staticFiles)
4343

4444
// Start mDNS broadcast
45-
log.Print("Start mDNS broadcast")
46-
publishHomeAssistant()
47-
defer mdns.Shutdown()
45+
go func() {
46+
log.Print("Start mDNS broadcast")
47+
publishHomeAssistant()
48+
defer mdns.Shutdown()
49+
}()
4850

4951
// Run webserver
5052
go func() {

0 commit comments

Comments
 (0)