Skip to content

Commit

Permalink
home: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Jan 25, 2021
1 parent 323fc01 commit 5c96f77
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion internal/home/controlinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ func (web *Web) handleInstallConfigure(w http.ResponseWriter, r *http.Request) {
config.DNS.BindHost = newSettings.DNS.IP
config.DNS.Port = newSettings.DNS.Port

// The background context is used because the underlying functions shut
// down the server, which handles current request.
err = StartMods(context.Background())
if err != nil {
Context.firstRun = true
Expand Down Expand Up @@ -361,7 +363,9 @@ func (web *Web) handleInstallConfigure(w http.ResponseWriter, r *http.Request) {
shut := func(srv *http.Server) {
defer cancel()
err := srv.Shutdown(ctx)
log.Debug("error while restarting HTTP server: %s", err)
if err != nil {
log.Debug("error while shutting down HTTP server: %s", err)
}
}
go shut(web.httpServer)
if web.httpServerBeta != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/home/controlupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func handleUpdate(w http.ResponseWriter, _ *http.Request) {
f.Flush()
}

// The background context is used because the underlying functions shut
// down the server, which handles current request.
go finishUpdate(context.Background())
}

Expand Down
6 changes: 3 additions & 3 deletions internal/home/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,12 @@ func run(args options) {
}

if !Context.firstRun {
err := initDNSServer(context.Background())
mainCtx := context.Background()
err := initDNSServer(mainCtx)
if err != nil {
log.Fatalf("%s", err)
}
Context.tls.Start(context.Background())
Context.tls.Start(mainCtx)
Context.autoHosts.Start()

go func() {
Expand Down Expand Up @@ -341,7 +342,6 @@ func StartMods(ctx context.Context) error {
return err
}

// May be 1 step up the trace
Context.tls.Start(ctx)

err = startDNSServer()
Expand Down
4 changes: 2 additions & 2 deletions internal/home/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ func (t *TLSMod) handleTLSConfigure(w http.ResponseWriter, r *http.Request) {
f.Flush()
}

// this needs to be done in a goroutine because Shutdown() is a blocking call, and it will block
// until all requests are finished, and _we_ are inside a request right now, so it will block indefinitely
// The background context is used because the TLSConfigChanged shuts
// down the server, which handles current request.
if restartHTTPS {
go func() {
Context.web.TLSConfigChanged(context.Background(), data)
Expand Down

0 comments on commit 5c96f77

Please sign in to comment.