From 2862119c1f1b14bc687e78a5feb5bfb7b748e458 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Wed, 24 Jan 2024 11:06:49 +0200 Subject: [PATCH] updated serve command error reporting --- cmd/serve.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index faface78..99ff0859 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -2,7 +2,6 @@ package cmd import ( "errors" - "log" "net/http" "github.com/pocketbase/pocketbase/apis" @@ -18,10 +17,11 @@ func NewServeCommand(app core.App, showStartBanner bool) *cobra.Command { var httpsAddr string command := &cobra.Command{ - Use: "serve [domain(s)]", - Args: cobra.ArbitraryArgs, - Short: "Starts the web server (default to 127.0.0.1:8090 if no domain is specified)", - Run: func(command *cobra.Command, args []string) { + Use: "serve [domain(s)]", + Args: cobra.ArbitraryArgs, + Short: "Starts the web server (default to 127.0.0.1:8090 if no domain is specified)", + SilenceUsage: true, + RunE: func(command *cobra.Command, args []string) error { // set default listener addresses if at least one domain is specified if len(args) > 0 { if httpAddr == "" { @@ -44,9 +44,11 @@ func NewServeCommand(app core.App, showStartBanner bool) *cobra.Command { CertificateDomains: args, }) - if !errors.Is(err, http.ErrServerClosed) { - log.Fatalln(err) + if errors.Is(err, http.ErrServerClosed) { + return nil } + + return err }, }