mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
fix build
This commit is contained in:
committed by
Aiden McClelland
parent
91d08ca650
commit
df50197c5f
@@ -139,7 +139,7 @@ async fn inner_main(cfg_path: Option<&str>) -> Result<(), Error> {
|
||||
log::error!("{}", e.source);
|
||||
log::debug!("{}", e.source);
|
||||
embassy::sound::BEETHOVEN.play().await?;
|
||||
let ctx = RecoveryContext::init(cfg_path).await?;
|
||||
let ctx = RecoveryContext::init(cfg_path, e).await?;
|
||||
rpc_server!({
|
||||
command: embassy::recovery_api,
|
||||
context: ctx.clone(),
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::ops::Deref;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use rpc_toolkit::yajrc::RpcError;
|
||||
use rpc_toolkit::Context;
|
||||
use serde::Deserialize;
|
||||
use tokio::fs::File;
|
||||
@@ -37,12 +38,13 @@ impl RecoveryContextConfig {
|
||||
pub struct RecoveryContextSeed {
|
||||
pub bind_rpc: SocketAddr,
|
||||
pub shutdown: Sender<()>,
|
||||
pub error: Arc<RpcError>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RecoveryContext(Arc<RecoveryContextSeed>);
|
||||
impl RecoveryContext {
|
||||
pub async fn init<P: AsRef<Path>>(path: Option<P>) -> Result<Self, Error> {
|
||||
pub async fn init<P: AsRef<Path>>(path: Option<P>, error: Error) -> Result<Self, Error> {
|
||||
let cfg = RecoveryContextConfig::load(path).await?;
|
||||
|
||||
let (shutdown, _) = tokio::sync::broadcast::channel(1);
|
||||
@@ -50,6 +52,7 @@ impl RecoveryContext {
|
||||
Ok(Self(Arc::new(RecoveryContextSeed {
|
||||
bind_rpc: cfg.bind_rpc.unwrap_or(([127, 0, 0, 1], 5959).into()),
|
||||
shutdown,
|
||||
error: Arc::new(error.into()),
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use rpc_toolkit::yajrc::RpcError;
|
||||
|
||||
use crate::context::RecoveryContext;
|
||||
use crate::logs::{display_logs, fetch_logs, LogResponse, LogSource};
|
||||
use crate::util::display_none;
|
||||
use crate::Error;
|
||||
|
||||
pub const SYSTEMD_UNIT: &'static str = "embassy-init";
|
||||
@@ -34,7 +35,8 @@ pub async fn logs(
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[command]
|
||||
#[command(display(display_none))]
|
||||
pub fn exit(#[context] ctx: RecoveryContext) -> Result<(), Error> {
|
||||
ctx.shutdown.send(()).expect("receiver dropped");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user