mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
add error status (#2746)
* add error status * update types * ṗ̶̰̙̓͒̈́ͅü̵̢̙̫̣ŗ̷̪̺̺͛g̴̲͉͎̬̒̇e̵̪̎̅͌ ̶̡̜̘͐͛t̶͎͍̣̿̍̐h̴͕̩͗̈́̎̑e̵͚͒̂͝ ̸̛͙̦͈͝v̶̱͙̬̽̔ọ̶̧̡̒̓i̸̬̲͍̋̈́d̴͉̀ * fix some extra voids * add `package.rebuild` * introduce error status and pkg rebuild and fix mocks * minor fixes * fix build --------- Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
@@ -589,6 +589,15 @@ impl ServiceActorSeed {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Parser, TS)]
|
||||
pub struct RebuildParams {
|
||||
pub id: PackageId,
|
||||
}
|
||||
pub async fn rebuild(ctx: RpcContext, RebuildParams { id }: RebuildParams) -> Result<(), Error> {
|
||||
ctx.services.load(&ctx, &id, LoadDisposition::Retry).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Parser, TS)]
|
||||
pub struct ConnectParams {
|
||||
pub id: PackageId,
|
||||
|
||||
@@ -7,6 +7,7 @@ use futures::{Future, FutureExt};
|
||||
use helpers::NonDetachingJoinHandle;
|
||||
use imbl::OrdMap;
|
||||
use imbl_value::InternedString;
|
||||
use models::ErrorData;
|
||||
use tokio::sync::{Mutex, OwnedRwLockReadGuard, OwnedRwLockWriteGuard, RwLock};
|
||||
use tracing::instrument;
|
||||
|
||||
@@ -22,6 +23,7 @@ use crate::progress::{FullProgressTracker, PhaseProgressTrackerHandle, ProgressT
|
||||
use crate::s9pk::manifest::PackageId;
|
||||
use crate::s9pk::merkle_archive::source::FileSource;
|
||||
use crate::s9pk::S9pk;
|
||||
use crate::service::start_stop::StartStop;
|
||||
use crate::service::{LoadDisposition, Service, ServiceRef};
|
||||
use crate::status::MainStatus;
|
||||
use crate::util::serde::Pem;
|
||||
@@ -87,8 +89,30 @@ impl ServiceMap {
|
||||
if let Some(service) = service.take() {
|
||||
shutdown_err = service.shutdown().await;
|
||||
}
|
||||
// TODO: retry on error?
|
||||
*service = Service::load(ctx, id, disposition).await?.map(From::from);
|
||||
match Service::load(ctx, id, disposition).await {
|
||||
Ok(s) => *service = s.into(),
|
||||
Err(e) => {
|
||||
let e = ErrorData::from(e);
|
||||
ctx.db
|
||||
.mutate(|db| {
|
||||
if let Some(pde) = db.as_public_mut().as_package_data_mut().as_idx_mut(id) {
|
||||
pde.as_status_mut().map_mutate(|s| {
|
||||
Ok(MainStatus::Error {
|
||||
on_rebuild: if s.running() {
|
||||
StartStop::Start
|
||||
} else {
|
||||
StartStop::Stop
|
||||
},
|
||||
message: e.details,
|
||||
debug: Some(e.debug),
|
||||
})
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
shutdown_err?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user