in src/local_gpu_verifier_http_service/cmd/local_gpu_verifier_http_service/main.go [53:104]
func main() {
// Initialize logger to output to stderr while we load configuration
initLogger("")
// Parse the command-line flags for service configuration
logPath := flag.String("logpath", defaultLogPath, "Path to the log file where service logs are written.")
port := flag.String("port", defaultPort, "Port on which the HTTP service will listen.")
verifierRoot := flag.String("verifierroot", defaultVerifierRoot, "Root directory for the GPU verifier, containing the Python script.")
successStr := flag.String("successstr", defaultSuccessString, "Message indicating successful attestation in command output.")
flag.Parse()
logger.Info("Loading service configuration...",
"logPath", *logPath,
"port", *port,
"verifierRoot", *verifierRoot,
"successStr", *successStr,
)
config := Config{
LogPath: *logPath,
Port: *port,
VerifierRoot: *verifierRoot,
SuccessStr: *successStr,
}
// Re-initialize the logger with file + console handlers
initLogger(config.LogPath)
// Log service startup details
logger.Info("Starting GPU Attestation HTTP Service", "port", config.Port)
logger.Info("Log file", "path", config.LogPath)
logger.Info("GPU attestation Verifier root directory", "path", config.VerifierRoot)
// Setup the HTTP server
mux := http.NewServeMux()
mux.HandleFunc("/gpu_attest", func(w http.ResponseWriter, r *http.Request) {
handleGpuAttest(w, r, config)
})
srv := &http.Server{
Addr: ":" + config.Port,
Handler: mux,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
}
// Start the HTTP server
if err := srv.ListenAndServe(); err != nil {
logger.Error("GPU Attestation HTTP Service failed to start", "err", err)
os.Exit(1)
}
}