commands: Avoid too many watch file handles causing the server to fail to start
authorShiming Zhang <wzshiming@foxmail.com>
Thu, 19 Aug 2021 09:04:09 +0000 (17:04 +0800)
committerGitHub <noreply@github.com>
Thu, 19 Aug 2021 09:04:09 +0000 (11:04 +0200)
Fixes #8904

commands/server.go

index 09cf43b249380d7fc63487ada85224e97cbbec8a..48e76da6b8b86b81657a726e482b9b48e8ebd355 100644 (file)
@@ -261,6 +261,11 @@ func (sc *serverCmd) server(cmd *cobra.Command, args []string) error {
                s.RegisterMediaTypes()
        }
 
+       err = c.serve(sc)
+       if err != nil {
+               return err
+       }
+
        // Watch runs its own server as part of the routine
        if sc.serverWatch {
 
@@ -283,7 +288,7 @@ func (sc *serverCmd) server(cmd *cobra.Command, args []string) error {
 
        }
 
-       return c.serve(sc)
+       return nil
 }
 
 func getRootWatchDirsStr(baseDir string, watchDirs []string) string {