don't construct the timezone every time a screenshot request is made

This commit is contained in:
Lily Tsuru 2024-09-30 07:37:39 -04:00
parent 7e1f5eddb6
commit be1d5e2f57

View file

@ -6,6 +6,8 @@ use tokio::task::JoinHandle;
use tracing::{Instrument, Level};
use tracing_subscriber::FmtSubscriber;
use tzfile::{ArcTz, Tz};
use serde::Deserialize;
use toml;
@ -62,6 +64,8 @@ async fn main() -> anyhow::Result<()> {
// Essentially this is meant to be a sentinel for "SCREENSHOT NOW!"
let (tx, _) = tokio::sync::broadcast::channel::<Option<()>>(10);
let gmt_timezone = ArcTz::new(Tz::named("GMT")?);
for (id, node) in config.vms.iter() {
tracing::info!("Adding node {id} : {:?}", node);
@ -70,12 +74,13 @@ async fn main() -> anyhow::Result<()> {
let node_clone = node.clone();
let root = config.root_path.clone();
let tz = gmt_timezone.clone();
let _: JoinHandle<anyhow::Result<()>> = tokio::spawn(async move {
while let Some(_) = _rx.recv().await? {
let span = tracing::span!(Level::INFO, "node screenshot", node = id_clone.as_str());
let zone = tzfile::Tz::named("GMT")?;
let now = { chrono::Utc::now().with_timezone(&&zone) };
let now = { chrono::Utc::now().with_timezone(&tz) };
let date_path = root.join(format!(
"{:02}-{:02}-{:02}",