(mut args: ServerArgs)
| 366 | reason = "Sequential startup flow, no natural split point" |
| 367 | )] |
| 368 | pub async fn server(mut args: ServerArgs) -> Result<(), Report<GraphError>> { |
| 369 | if args.healthcheck.healthcheck { |
| 370 | return wait_healthcheck( |
| 371 | || healthcheck(args.config.http_address.clone()), |
| 372 | &args.healthcheck, |
| 373 | ) |
| 374 | .await |
| 375 | .change_context(GraphError); |
| 376 | } |
| 377 | |
| 378 | let pool = PostgresStorePool::new( |
| 379 | &args.db_info, |
| 380 | &args.db_pool_config, |
| 381 | NoTls, |
| 382 | PostgresStoreSettings { |
| 383 | validate_links: !args.config.skip_link_validation, |
| 384 | skip_embedding_creation: args.config.skip_embedding_creation, |
| 385 | filter_protection: if args.config.skip_filter_protection { |
| 386 | PropertyProtectionFilterConfig::new() |
| 387 | } else { |
| 388 | PropertyProtectionFilterConfig::hash_default() |
| 389 | }, |
| 390 | }, |
| 391 | ) |
| 392 | .await |
| 393 | .change_context(GraphError) |
| 394 | .map_err(|report| { |
| 395 | tracing::error!(error = ?report, "Failed to connect to database"); |
| 396 | report |
| 397 | })?; |
| 398 | |
| 399 | // Just test the connection; we don't need to use the store |
| 400 | _ = pool |
| 401 | .acquire(None) |
| 402 | .await |
| 403 | .change_context(GraphError) |
| 404 | .attach("Connection to database failed")?; |
| 405 | |
| 406 | let lifecycle = ServerLifecycle::new(); |
| 407 | |
| 408 | if args.embed_admin { |
| 409 | start_admin_server(pool.clone(), args.admin, &lifecycle); |
| 410 | } |
| 411 | |
| 412 | if args.embed_type_fetcher { |
| 413 | start_type_fetcher(args.type_fetcher.clone(), &lifecycle); |
| 414 | } |
| 415 | |
| 416 | let pool = FetchingPool::new( |
| 417 | pool, |
| 418 | ( |
| 419 | args.type_fetcher.address.type_fetcher_host, |
| 420 | args.type_fetcher.address.type_fetcher_port, |
| 421 | ), |
| 422 | DomainValidator::new(args.config.allowed_url_domain.clone()), |
| 423 | ); |
| 424 | |
| 425 | let log_queries = args.config.log_queries.take(); |
no test coverage detected