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