Skip to content

Commit

Permalink
Read JWT_PRIVATE_KEY from env
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Sep 9, 2024
1 parent a1f2311 commit f03296e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions notification-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ func loadNotifConfig() {
logLevel = key.String()
}

if key, err := section.GetKey("jwt_private_key"); err == nil {
privateKey = key.String()
}

level, err := log.ParseLevel(logLevel)
if err != nil {
log.Info("use the default log level: info")
Expand Down Expand Up @@ -201,6 +197,10 @@ func main() {
fp.Close()
}

if err := loadJwtPrivateKey(); err != nil {
log.Fatalf("Failed to read config: %v", err)
}

loadNotifConfig()
loadCcnetDB()

Expand All @@ -219,6 +219,15 @@ func main() {
}
}

func loadJwtPrivateKey() error {
privateKey = os.Getenv("JWT_PRIVATE_KEY")
if privateKey == "" {
return fmt.Errorf("failed to read JWT_PRIVATE_KEY")
}

return nil
}

func handleUser1Signal() {
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGUSR1)
Expand Down

0 comments on commit f03296e

Please sign in to comment.