Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
broker: Fatal error when a networkserver token can't be read
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Gourlaouen authored and htdvisser committed Dec 22, 2017
1 parent 997ecc3 commit 33b404a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
ttnlog "github.com/TheThingsNetwork/go-utils/log"
"github.com/TheThingsNetwork/ttn/core/broker"
"github.com/TheThingsNetwork/ttn/core/component"
"github.com/dgrijalva/jwt-go"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -56,7 +57,11 @@ var brokerCmd = &cobra.Command{
broker := broker.NewBroker(
time.Duration(viper.GetInt("broker.deduplication-delay")) * time.Millisecond,
)
broker.SetNetworkServer(viper.GetString("broker.networkserver-address"), nsCert, viper.GetString("broker.networkserver-token"))
nsToken := viper.GetString("broker.networkserver-token")
if _, err := jwt.Parse(nsToken, func(*jwt.Token) (interface{}, error) { return nil, nil }); nsToken != "" && err != nil {
ctx.WithError(err).Fatal("Could not read networkserver token")
}
broker.SetNetworkServer(viper.GetString("broker.networkserver-address"), nsCert, nsToken)
err = broker.Init(component)
if err != nil {
ctx.WithError(err).Fatal("Could not initialize broker")
Expand Down

0 comments on commit 33b404a

Please sign in to comment.