init: scaffold from k-template with postgres + worker

This commit is contained in:
2026-05-31 03:08:38 +02:00
commit f9cb142c3b
70 changed files with 5269 additions and 0 deletions

34
crates/worker/src/main.rs Normal file
View File

@@ -0,0 +1,34 @@
use std::sync::Arc;
use std::time::Duration;
use tracing::info;
mod config;
mod job;
mod jobs;
mod runner;
use jobs::ExampleJob;
use runner::JobRunner;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::from_default_env()
.add_directive("worker=info".parse()?),
)
.init();
let config = config::WorkerConfig::from_env();
info!("Worker starting");
let _pool = adapters_sqlite::connect(&config.database_url).await?;
adapters_sqlite::run_migrations(&_pool).await?;
let interval = Duration::from_secs(config.example_job_interval_secs);
let runner = JobRunner::new().register(Arc::new(ExampleJob), interval);
info!("Worker running");
runner.run().await;
Ok(())
}