don't construct the timezone every time a screenshot request is made
This commit is contained in:
parent
7e1f5eddb6
commit
be1d5e2f57
1 changed files with 7 additions and 2 deletions
|
@ -6,6 +6,8 @@ use tokio::task::JoinHandle;
|
||||||
use tracing::{Instrument, Level};
|
use tracing::{Instrument, Level};
|
||||||
use tracing_subscriber::FmtSubscriber;
|
use tracing_subscriber::FmtSubscriber;
|
||||||
|
|
||||||
|
use tzfile::{ArcTz, Tz};
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
|
@ -62,6 +64,8 @@ async fn main() -> anyhow::Result<()> {
|
||||||
// Essentially this is meant to be a sentinel for "SCREENSHOT NOW!"
|
// Essentially this is meant to be a sentinel for "SCREENSHOT NOW!"
|
||||||
let (tx, _) = tokio::sync::broadcast::channel::<Option<()>>(10);
|
let (tx, _) = tokio::sync::broadcast::channel::<Option<()>>(10);
|
||||||
|
|
||||||
|
let gmt_timezone = ArcTz::new(Tz::named("GMT")?);
|
||||||
|
|
||||||
for (id, node) in config.vms.iter() {
|
for (id, node) in config.vms.iter() {
|
||||||
tracing::info!("Adding node {id} : {:?}", node);
|
tracing::info!("Adding node {id} : {:?}", node);
|
||||||
|
|
||||||
|
@ -70,12 +74,13 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let node_clone = node.clone();
|
let node_clone = node.clone();
|
||||||
let root = config.root_path.clone();
|
let root = config.root_path.clone();
|
||||||
|
|
||||||
|
let tz = gmt_timezone.clone();
|
||||||
|
|
||||||
let _: JoinHandle<anyhow::Result<()>> = tokio::spawn(async move {
|
let _: JoinHandle<anyhow::Result<()>> = tokio::spawn(async move {
|
||||||
while let Some(_) = _rx.recv().await? {
|
while let Some(_) = _rx.recv().await? {
|
||||||
let span = tracing::span!(Level::INFO, "node screenshot", node = id_clone.as_str());
|
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(&tz) };
|
||||||
let now = { chrono::Utc::now().with_timezone(&&zone) };
|
|
||||||
|
|
||||||
let date_path = root.join(format!(
|
let date_path = root.join(format!(
|
||||||
"{:02}-{:02}-{:02}",
|
"{:02}-{:02}-{:02}",
|
||||||
|
|
Loading…
Reference in a new issue