Skip to content

Commit

Permalink
updated serve command error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Jan 24, 2024
1 parent eaf121e commit 2862119
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"errors"
"log"
"net/http"

"github.com/pocketbase/pocketbase/apis"
Expand All @@ -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 == "" {
Expand All @@ -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
},
}

Expand Down

0 comments on commit 2862119

Please sign in to comment.