Skip to content

Commit

Permalink
only stop app if connection is closed (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
hooksie1 authored Aug 22, 2024
1 parent 8d9b748 commit bf543c9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
cwnats "github.com/CoverWhale/coverwhale-go/transports/nats"
"github.com/CoverWhale/logr"
"github.com/hooksie1/piggybank/service"
"github.com/nats-io/nats.go"
"github.com/nats-io/nats.go/micro"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -75,7 +76,9 @@ func start(cmd *cobra.Command, args []string) error {

health := func(ch chan<- string, s micro.Service) {
a := <-nc.StatusChanged()
ch <- fmt.Sprintf("%s %s", a.String(), nc.LastError())
if a == nats.CLOSED {
ch <- fmt.Sprintf("%s last error: %v", a.String(), nc.LastError())
}
}

return cwnats.HandleNotify(svc, health)
Expand Down

0 comments on commit bf543c9

Please sign in to comment.