Skip to content

Commit

Permalink
chore: move start logs to api and utxorpc (#244)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 authored Sep 6, 2024
1 parent af99608 commit c3e0a53
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
10 changes: 0 additions & 10 deletions cmd/cardano-node-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,13 @@ func main() {
}

// Start API listener
logger.Infof(
"starting API listener on %s:%d",
cfg.Api.ListenAddress,
cfg.Api.ListenPort,
)
go func() {
if err := api.Start(cfg); err != nil {
logger.Fatalf("failed to start API: %s", err)
}
}()

// Start UTxO RPC gRPC listener
logger.Infof(
"starting gRPC listener on %s:%d",
cfg.Utxorpc.ListenAddress,
cfg.Utxorpc.ListenPort,
)
if err := utxorpc.Start(cfg); err != nil {
logger.Fatalf("failed to start gRPC: %s", err)
}
Expand Down
17 changes: 15 additions & 2 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ import (
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func Start(cfg *config.Config) error {
// Standard logging
logger := logging.GetLogger()
if cfg.Tls.CertFilePath != "" && cfg.Tls.KeyFilePath != "" {
logger.Infof(
"starting API TLS listener on %s:%d",
cfg.Api.ListenAddress,
cfg.Api.ListenPort,
)
} else {
logger.Infof(
"starting API listener on %s:%d",
cfg.Api.ListenAddress,
cfg.Api.ListenPort,
)
}
// Disable gin debug and color output
gin.SetMode(gin.ReleaseMode)
gin.DisableConsoleColor()
Expand All @@ -50,8 +65,6 @@ func Start(cfg *config.Config) error {
router := gin.New()
// Catch panics and return a 500
router.Use(gin.Recovery())
// Standard logging
logger := logging.GetLogger()
// Access logging
accessLogger := logging.GetAccessLogger()
skipPaths := []string{}
Expand Down
16 changes: 16 additions & 0 deletions internal/utxorpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,25 @@ import (
"golang.org/x/net/http2/h2c"

"github.com/blinklabs-io/cardano-node-api/internal/config"
"github.com/blinklabs-io/cardano-node-api/internal/logging"
)

func Start(cfg *config.Config) error {
// Standard logging
logger := logging.GetLogger()
if cfg.Tls.CertFilePath != "" && cfg.Tls.KeyFilePath != "" {
logger.Infof(
"starting gRPC TLS listener on %s:%d",
cfg.Utxorpc.ListenAddress,
cfg.Utxorpc.ListenPort,
)
} else {
logger.Infof(
"starting gRPC listener on %s:%d",
cfg.Utxorpc.ListenAddress,
cfg.Utxorpc.ListenPort,
)
}
mux := http.NewServeMux()
compress1KB := connect.WithCompressMinBytes(1024)
queryPath, queryHandler := queryconnect.NewQueryServiceHandler(
Expand Down

0 comments on commit c3e0a53

Please sign in to comment.