move media startup into service
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
38c989a07e
commit
aa7a310200
|
@ -3,6 +3,7 @@ mod tests;
|
||||||
|
|
||||||
use std::{collections::HashMap, io::Cursor, num::Saturating as Sat, path::PathBuf, sync::Arc, time::SystemTime};
|
use std::{collections::HashMap, io::Cursor, num::Saturating as Sat, path::PathBuf, sync::Arc, time::SystemTime};
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
use base64::{engine::general_purpose, Engine as _};
|
use base64::{engine::general_purpose, Engine as _};
|
||||||
use conduit::{checked, debug, debug_error, error, utils, Error, Result, Server};
|
use conduit::{checked, debug, debug_error, error, utils, Error, Result, Server};
|
||||||
use data::Data;
|
use data::Data;
|
||||||
|
@ -47,6 +48,7 @@ pub struct Service {
|
||||||
pub url_preview_mutex: RwLock<HashMap<String, Arc<Mutex<()>>>>,
|
pub url_preview_mutex: RwLock<HashMap<String, Arc<Mutex<()>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
impl crate::Service for Service {
|
impl crate::Service for Service {
|
||||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||||
Ok(Arc::new(Self {
|
Ok(Arc::new(Self {
|
||||||
|
@ -56,6 +58,12 @@ impl crate::Service for Service {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn worker(self: Arc<Self>) -> Result<()> {
|
||||||
|
self.create_media_dir().await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
|
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,6 @@ impl Services {
|
||||||
pub(super) async fn start(&self) -> Result<()> {
|
pub(super) async fn start(&self) -> Result<()> {
|
||||||
debug_info!("Starting services...");
|
debug_info!("Starting services...");
|
||||||
|
|
||||||
self.media.create_media_dir().await?;
|
|
||||||
globals::migrations::migrations(&self.db, &self.globals.config).await?;
|
globals::migrations::migrations(&self.db, &self.globals.config).await?;
|
||||||
globals::emerg_access::init_emergency_access();
|
globals::emerg_access::init_emergency_access();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue