Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

http: fix serve http exits directly after starting

Cnlybc74f0621ef6
diff --git a/cmd/serve/http/http.go b/cmd/serve/http/http.go
index dab1489d7..592580826 100644
--- a/cmd/serve/http/http.go
+++ b/cmd/serve/http/http.go
@@ -69,6 +69,7 @@ control the stats printing.
return err
}
s.Bind(router)
+ httplib.Wait()
return nil
})
},
diff --git a/lib/http/http.go b/lib/http/http.go
index 61525bab4..28c2596d7 100644
--- a/lib/http/http.go
+++ b/lib/http/http.go
@@ -231,6 +231,11 @@ func (s *server) Serve() {
}
}
+// Wait blocks while the server is serving requests
+func (s *server) Wait() {
+ s.closing.Wait()
+}
+
// Router returns the server base router
func (s *server) Router() chi.Router {
return s.baseRouter
@@ -291,6 +296,11 @@ func Restart() error {
return start()
}
+// Wait blocks while the default http server is serving requests
+func Wait() {
+ defaultServer.Wait()
+}
+
// Start the default server
func start() error {
defaultServerMutex.Lock()