Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move start logs to api and utxorpc #244

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading