+ let router_persist = Arc::clone(&router);
+ tokio::spawn(async move {
+ let mut interval = tokio::time::interval(Duration::from_secs(600));
+ loop {
+ interval.tick().await;
+ if disk::persist_network(
+ Path::new(&network_graph_path),
+ &*router_persist.network_graph.read().unwrap(),
+ )
+ .is_err()
+ {
+ // Persistence errors here are non-fatal as we can just fetch the routing graph
+ // again later, but they may indicate a disk error which could be fatal elsewhere.
+ eprintln!(
+ "Warning: Failed to persist network graph, check your disk and permissions"
+ );
+ }
+ }
+ });