Skip to main content
Glama
server.rs1.58 kB
use std::sync::Arc; use telemetry::prelude::*; use tokio_util::sync::CancellationToken; use crate::{ DefaultServiceEndpoints, Result, ServiceEndpointsConfig, }; pub struct EndpointsServer { service: Arc<DefaultServiceEndpoints>, config: ServiceEndpointsConfig, shutdown_token: CancellationToken, } impl EndpointsServer { pub fn new( service: Arc<DefaultServiceEndpoints>, config: ServiceEndpointsConfig, shutdown_token: CancellationToken, ) -> Self { Self { service, config, shutdown_token, } } pub async fn run(self) -> Result<()> { if !self.config.enabled { return Ok(()); } let app = crate::axum_integration::create_router(self.service.clone(), &self.config); let listener = tokio::net::TcpListener::bind(&self.config.bind_address).await?; let actual_addr = listener.local_addr()?; info!( service = self.service.service_name(), address = %actual_addr, health_endpoint = self.config.health_endpoint, config_endpoint = self.config.config_endpoint, "service endpoints listening" ); axum::Server::from_tcp(listener.into_std()?) .map_err(std::io::Error::other)? .serve(app.into_make_service()) .with_graceful_shutdown(async move { self.shutdown_token.cancelled().await; }) .await .map_err(std::io::Error::other)?; Ok(()) } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server