MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / run_server

Function run_server

crates/openshell-server/src/lib.rs:211–492  ·  view source on GitHub ↗

Run the `OpenShell` server. This starts a multiplexed gRPC/HTTP server on the configured bind address. # Errors Returns an error if the server fails to start or encounters a fatal error.

(
    startup: ServerStartupConfig,
    tracing_log_bus: TracingLogBus,
)

Source from the content-addressed store, hash-verified

209///
210/// Returns an error if the server fails to start or encounters a fatal error.
211pub(crate) async fn run_server(
212 startup: ServerStartupConfig,
213 tracing_log_bus: TracingLogBus,
214) -> Result<()> {
215 let ServerStartupConfig {
216 config,
217 config_file,
218 guest_tls,
219 } = startup;
220
221 let database_url = config.database_url.trim();
222 if database_url.is_empty() {
223 return Err(Error::config("database_url is required"));
224 }
225
226 let store = Arc::new(Store::connect(database_url).await?);
227
228 let oidc_cache = if let Some(ref oidc) = config.oidc {
229 // Validate RBAC configuration before starting.
230 let policy = auth::authz::AuthzPolicy {
231 admin_role: oidc.admin_role.clone(),
232 user_role: oidc.user_role.clone(),
233 scopes_enabled: !oidc.scopes_claim.is_empty(),
234 };
235 policy.validate().map_err(Error::config)?;
236
237 let cache = auth::oidc::JwksCache::new(oidc)
238 .await
239 .map_err(|e| Error::config(format!("OIDC initialization failed: {e}")))?;
240 info!("OIDC JWT validation enabled (issuer: {})", oidc.issuer);
241 Some(Arc::new(cache))
242 } else {
243 None
244 };
245
246 let sandbox_index = SandboxIndex::new();
247 let sandbox_watch_bus = SandboxWatchBus::new();
248 let supervisor_sessions = Arc::new(supervisor_session::SupervisorSessionRegistry::new());
249 let driver_startup = compute::driver_config::DriverStartupContext {
250 file: config_file.as_ref(),
251 guest_tls: guest_tls.as_ref(),
252 gateway_port: config.bind_address.port(),
253 gateway_tls_enabled: config.tls.is_some(),
254 endpoint_overrides: &config.compute_driver_endpoints,
255 };
256 let compute = build_compute_runtime(
257 &config,
258 driver_startup,
259 store.clone(),
260 sandbox_index.clone(),
261 sandbox_watch_bus.clone(),
262 tracing_log_bus.clone(),
263 supervisor_sessions.clone(),
264 )
265 .await?;
266 let mut state = ServerState::new(
267 config.clone(),
268 store.clone(),

Callers 1

run_from_argsFunction · 0.70

Calls 15

configFunction · 0.85
connectFunction · 0.85
build_compute_runtimeFunction · 0.85
spawn_session_reaperFunction · 0.85
spawn_relay_reaperFunction · 0.85
spawn_refresh_workerFunction · 0.85
health_routerFunction · 0.85
metrics_routerFunction · 0.85
serve_gateway_listenerFunction · 0.85
shutdown_signalFunction · 0.85

Tested by

no test coverage detected