@@ -2,6 +2,7 @@ package main
22
33import (
44 "context"
5+ "encoding/json"
56 "fmt"
67 "log"
78 "os"
@@ -15,6 +16,7 @@ import (
1516 "github.com/nextinterfaces/semcache-service/internal/database"
1617 "github.com/nextinterfaces/semcache-service/internal/handlers"
1718 "github.com/nextinterfaces/semcache-service/internal/models"
19+ "github.com/nextinterfaces/semcache-service/internal/util"
1820 "go.opentelemetry.io/otel"
1921 "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
2022 "go.opentelemetry.io/otel/sdk/resource"
@@ -29,16 +31,14 @@ func main() {
2931}
3032
3133func run () error {
32- // Load configuration
3334 cfg , err := config .Load ()
35+ cfgJSON , _ := json .MarshalIndent (util .RedactedConfig (cfg ), "" , " " )
36+ log .Println ("Loaded configuration:\n " + string (cfgJSON ))
3437 if err != nil {
3538 return fmt .Errorf ("failed to load config: %w" , err )
3639 }
3740
38- log .Printf ("Starting semcache-service on port %d" , cfg .Server .Port )
39- log .Printf ("Commit SHA: %s" , cfg .Server .CommitSHA )
40-
41- // Initialize OpenTelemetry if enabled
41+ // Initialize OpenTelemetry
4242 if cfg .OTEL .Enabled {
4343 shutdown , err := initTracer (cfg )
4444 if err != nil {
@@ -79,32 +79,28 @@ func run() error {
7979 e .Use (middleware .Recover ())
8080 e .Use (middleware .CORS ())
8181
82- // Routes
8382 e .GET ("/v1/health" , h .Health )
8483
85- // API Documentation routes
8684 e .GET ("/docs" , h .ServeSwaggerUI )
8785 e .GET ("/api/openapi.yaml" , h .ServeOpenAPISpec )
8886
89- // API routes
9087 api := e .Group ("/v1" )
9188 api .POST ("/create" , h .Create )
9289 api .POST ("/search" , h .Search )
9390
94- // Start server in a goroutine
91+ port := cfg . Server . Port
9592 go func () {
96- addr := fmt .Sprintf (":%d" , cfg . Server . Port )
93+ addr := fmt .Sprintf (":%d" , port )
9794 if err := e .Start (addr ); err != nil {
9895 log .Printf ("Server error: %v" , err )
9996 }
10097 }()
10198
102- log .Printf ("Server started successfully on port %d" , cfg .Server .Port )
103- log .Printf ("Health check: http://localhost:%d/v1/health" , cfg .Server .Port )
104- log .Printf ("API Documentation: http://localhost:%d/docs" , cfg .Server .Port )
105- log .Printf ("API endpoints:" )
106- log .Printf (" POST http://localhost:%d/v1/create" , cfg .Server .Port )
107- log .Printf (" POST http://localhost:%d/v1/search" , cfg .Server .Port )
99+ log .Printf ("Server started, endpoints:" )
100+ log .Printf (" http://localhost:%d/v1/health" , port )
101+ log .Printf (" http://localhost:%d/docs" , port )
102+ log .Printf (" POST http://localhost:%d/v1/create" , port )
103+ log .Printf (" POST http://localhost:%d/v1/search" , port )
108104
109105 // Wait for interrupt signal to gracefully shutdown the server
110106 quit := make (chan os.Signal , 1 )
0 commit comments