Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Introduce Kubernetes liveness probe to ensure database works
Antonio Scandurra9328bb0153d5
diff --git a/crates/collab/k8s/manifest.template.yml b/crates/collab/k8s/manifest.template.ymlindex 339d02892ef..b73070536f1 100644--- a/crates/collab/k8s/manifest.template.yml+++ b/crates/collab/k8s/manifest.template.yml@@ -59,6 +59,13 @@ spec:ports:- containerPort: 8080protocol: TCP+ livenessProbe:+ httpGet:+ path: /healthz+ port: 8080+ initialDelaySeconds: 5+ periodSeconds: 5+ timeoutSeconds: 5readinessProbe:httpGet:path: /diff --git a/crates/collab/src/main.rs b/crates/collab/src/main.rsindex 0f783c13e58..30ed35bc354 100644--- a/crates/collab/src/main.rs+++ b/crates/collab/src/main.rs@@ -1,11 +1,12 @@use anyhow::anyhow;-use axum::{routing::get, Router};+use axum::{routing::get, Extension, Router};use collab::{db, env, executor::Executor, AppState, Config, MigrateConfig, Result};use db::Database;use std::{env::args,net::{SocketAddr, TcpListener},path::Path,+ sync::Arc,};use tokio::signal::unix::SignalKind;use tracing_log::LogTracer;@@ -66,7 +67,12 @@ async fn main() -> Result<()> {let app = collab::api::routes(rpc_server.clone(), state.clone()).merge(collab::rpc::routes(rpc_server.clone()))- .merge(Router::new().route("/", get(handle_root)));+ .merge(+ Router::new()+ .route("/", get(handle_root))+ .route("/healthz", get(handle_liveness_probe))+ .layer(Extension(state.clone())),+ );axum::Server::from_tcp(listener)?.serve(app.into_make_service_with_connect_info::<SocketAddr>())@@ -95,6 +101,11 @@ async fn handle_root() -> String {format!("collab v{VERSION}")}+async fn handle_liveness_probe(Extension(state): Extension<Arc<AppState>>) -> Result<String> {+ state.db.get_all_users(0, 1).await?;+ Ok("ok".to_string())+}+pub fn init_tracing(config: &Config) -> Option<()> {use std::str::FromStr;use tracing_subscriber::layer::SubscriberExt;