Skip to content

Commit

Permalink
Fix image
Browse files Browse the repository at this point in the history
  • Loading branch information
max-lt committed Mar 23, 2024
1 parent 238065a commit a303386
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
16 changes: 15 additions & 1 deletion bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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 || {
Expand Down

0 comments on commit a303386

Please sign in to comment.