play song during update (#1832)

* play song

* change song
This commit is contained in:
Aiden McClelland
2022-09-26 16:52:12 -06:00
committed by GitHub
parent 8cf84a6cf2
commit 31c5aebe90
3 changed files with 20 additions and 38 deletions

View File

@@ -4,12 +4,14 @@ use std::process::Stdio;
use std::time::Duration;
use color_eyre::eyre::eyre;
use helpers::NonDetachingJoinHandle;
use patch_db::{DbHandle, LockReceipt, LockType};
use tokio::process::Command;
use crate::context::rpc::RpcContextConfig;
use crate::db::model::ServerStatus;
use crate::install::PKG_DOCKER_DIR;
use crate::sound::CIRCLE_OF_5THS_SHORT;
use crate::util::Invoke;
use crate::version::VersionT;
use crate::Error;
@@ -196,6 +198,17 @@ pub async fn init(cfg: &RpcContextConfig) -> Result<InitResult, Error> {
|| &*receipts.server_version.get(&mut handle).await?
< &crate::version::Current::new().semver();
let song = if should_rebuild {
Some(NonDetachingJoinHandle::from(tokio::spawn(async {
loop {
CIRCLE_OF_5THS_SHORT.play().await.unwrap();
tokio::time::sleep(Duration::from_secs(10)).await;
}
})))
} else {
None
};
let log_dir = cfg.datadir().join("main/logs");
if tokio::fs::metadata(&log_dir).await.is_err() {
tokio::fs::create_dir_all(&log_dir).await?;
@@ -331,6 +344,8 @@ pub async fn init(cfg: &RpcContextConfig) -> Result<InitResult, Error> {
}?;
}
drop(song);
tracing::info!("System initialized.");
Ok(InitResult { db })

View File

@@ -109,8 +109,8 @@ impl SoundInterface {
}
pub struct Song<Notes> {
tempo_qpm: u16,
note_sequence: Notes,
pub tempo_qpm: u16,
pub note_sequence: Notes,
}
impl<'a, T> Song<T>
where
@@ -157,8 +157,8 @@ impl Drop for SoundInterface {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Arbitrary)]
pub struct Note {
semitone: Semitone,
octave: i8,
pub semitone: Semitone,
pub octave: i8,
}
impl Note {
pub fn frequency(&self) -> f64 {