Initial code commit
CI / test (push) Successful in 5m7s

This commit is contained in:
IxianPixel committed 2026-11-05 14:19:37 +00:00
1 parent f47217d5a3
commit 8ceb3c8be8
60 files changed
+10884

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
//! The jellymove daemon: HTTP API, embedded UI, job runner and source exports.
pub mod api;
pub mod config;
pub mod export;
pub mod library;
pub mod peer;
pub mod runner;
pub mod state;
pub mod ui;
use std::sync::Arc;
pub use config::Config;
use tower_http::trace::TraceLayer;
/// Open state, resume interrupted jobs and serve until shutdown.
pub async fn run(cfg: Config) -> anyhow::Result<()> {
std::fs::create_dir_all(&cfg.data_dir)?;
let store = jm_store::Store::open(&cfg.data_dir.join("jellymove.db"))?;
let listen = cfg.listen;
let state = Arc::new(state::AppState::new(cfg, store)?);
match state.jellyfin.system_info().await {
Ok(i) => {
tracing::info!(server = %i.server_name, version = %i.version, "connected to Jellyfin")
}
Err(e) => {
tracing::warn!(error = %e, "can't reach Jellyfin yet; will keep trying on demand")
}
}
runner::resume_all(&state).await?;
let app = api::router(state.clone()).layer(TraceLayer::new_for_http());
let listener = tokio::net::TcpListener::bind(listen).await?;
tracing::info!(%listen, node = %state.cfg.node_name, "jellymove listening");
axum::serve(listener, app)
.with_graceful_shutdown(shutdown_signal())
.await?;
Ok(())
}
async fn shutdown_signal() {
let ctrl_c = async {
let _ = tokio::signal::ctrl_c().await;
};
#[cfg(unix)]
let term = async {
if let Ok(mut s) = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
{
s.recv().await;
}
};
#[cfg(not(unix))]
let term = std::future::pending::<()>();
tokio::select! { _ = ctrl_c => {}, _ = term => {} }
tracing::info!("shutting down; in-flight transfers will resume on next start");
}