diff --git a/Dockerfile b/Dockerfile index f178f6b..e67f71d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,10 @@ RUN --mount=type=cache,target=~/.cargo \ FROM debian:bookworm-slim +RUN apt-get update \ + && apt-get install -y ca-certificates \ + && rm -rf /var/lib/apt/lists/* + COPY --from=builder /build/output /usr/local/bin/openworkers-runner CMD ["/usr/local/bin/openworkers-runner"] diff --git a/bin/main.rs b/bin/main.rs index 1784ddc..2943db8 100644 --- a/bin/main.rs +++ b/bin/main.rs @@ -202,7 +202,10 @@ async fn main() -> std::io::Result<()> { debug!("DATABASE_URL not set, using POSTGRES_* env vars"); - std::env::set_var("DATABASE_URL", format!("postgres://{user}:{password}@{host}:{port}/{database}")); + std::env::set_var( + "DATABASE_URL", + format!("postgres://{user}:{password}@{host}:{port}/{database}"), + ); } let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); @@ -212,6 +215,17 @@ async fn main() -> std::io::Result<()> { .await .expect("Failed to connect to Postgres"); + // Check postgres connection + sqlx::query("SELECT 1") + .fetch_one(&pool) + .await + .expect("Failed to query Postgres"); + debug!("connected to Postgres"); + + // Check NATS connection + openworkers_runner::nats::nats_connect().publish("boot", "0").expect("Failed to connect to NATS"); + debug!("connected to NATS"); + openworkers_runner::scheduled::handle_scheduled(pool.clone()); HttpServer::new(move || {