diff --git a/core/startos/src/service/service_effect_handler.rs b/core/startos/src/service/service_effect_handler.rs index bcd6da7d1..a61a00b9b 100644 --- a/core/startos/src/service/service_effect_handler.rs +++ b/core/startos/src/service/service_effect_handler.rs @@ -64,56 +64,6 @@ impl EffectContext { } } -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct WithProcedureId { - #[serde(default)] - procedure_id: Guid, - #[serde(flatten)] - rest: T, -} -impl FromArgMatches for WithProcedureId { - fn from_arg_matches(matches: &clap::ArgMatches) -> Result { - let rest = T::from_arg_matches(matches)?; - Ok(Self { - procedure_id: matches.get_one("procedure-id").cloned().unwrap_or_default(), - rest, - }) - } - fn from_arg_matches_mut(matches: &mut clap::ArgMatches) -> Result { - let rest = T::from_arg_matches_mut(matches)?; - Ok(Self { - procedure_id: matches.get_one("procedure-id").cloned().unwrap_or_default(), - rest, - }) - } - fn update_from_arg_matches(&mut self, matches: &clap::ArgMatches) -> Result<(), clap::Error> { - self.rest.update_from_arg_matches(matches)?; - self.procedure_id = matches.get_one("procedure-id").cloned().unwrap_or_default(); - Ok(()) - } - fn update_from_arg_matches_mut( - &mut self, - matches: &mut clap::ArgMatches, - ) -> Result<(), clap::Error> { - self.rest.update_from_arg_matches_mut(matches)?; - self.procedure_id = matches.get_one("procedure-id").cloned().unwrap_or_default(); - Ok(()) - } -} -impl CommandFactory for WithProcedureId { - fn command() -> clap::Command { - T::command_for_update().arg( - clap::Arg::new("procedure-id") - .action(clap::ArgAction::Set) - .value_parser(clap::value_parser!(Guid)), - ) - } - fn command_for_update() -> clap::Command { - Self::command() - } -} - pub fn service_effect_handler() -> ParentHandler { ParentHandler::new() .subcommand("gitInfo", from_fn(|_: C| crate::version::git_info())) @@ -877,6 +827,8 @@ async fn exists(context: EffectContext, params: ParamsPackageId) -> Result, #[ts(type = "string")] @@ -886,15 +838,12 @@ struct ExecuteAction { } async fn execute_action( context: EffectContext, - WithProcedureId { + ExecuteAction { procedure_id, - rest: - ExecuteAction { - service_id, - action_id, - input, - }, - }: WithProcedureId, + service_id, + action_id, + input, + }: ExecuteAction, ) -> Result { let context = context.deref()?; let package_id = service_id @@ -950,9 +899,53 @@ async fn running(context: EffectContext, params: ParamsPackageId) -> Result Result { + Ok(Self { + procedure_id: matches.get_one("procedure-id").cloned().unwrap_or_default(), + }) + } + fn from_arg_matches_mut(matches: &mut clap::ArgMatches) -> Result { + Ok(Self { + procedure_id: matches.get_one("procedure-id").cloned().unwrap_or_default(), + }) + } + fn update_from_arg_matches(&mut self, matches: &clap::ArgMatches) -> Result<(), clap::Error> { + self.procedure_id = matches.get_one("procedure-id").cloned().unwrap_or_default(); + Ok(()) + } + fn update_from_arg_matches_mut( + &mut self, + matches: &mut clap::ArgMatches, + ) -> Result<(), clap::Error> { + self.procedure_id = matches.get_one("procedure-id").cloned().unwrap_or_default(); + Ok(()) + } +} +impl CommandFactory for ProcedureId { + fn command() -> clap::Command { + Self::command_for_update().arg( + clap::Arg::new("procedure-id") + .action(clap::ArgAction::Set) + .value_parser(clap::value_parser!(Guid)), + ) + } + fn command_for_update() -> clap::Command { + Self::command() + } +} + async fn restart( context: EffectContext, - WithProcedureId { procedure_id, .. }: WithProcedureId, + ProcedureId { procedure_id }: ProcedureId, ) -> Result<(), Error> { let context = context.deref()?; context.restart(procedure_id).await?; @@ -961,7 +954,7 @@ async fn restart( async fn shutdown( context: EffectContext, - WithProcedureId { procedure_id, .. }: WithProcedureId, + ProcedureId { procedure_id }: ProcedureId, ) -> Result<(), Error> { let context = context.deref()?; context.stop(procedure_id).await?; @@ -1001,7 +994,6 @@ async fn set_configured(context: EffectContext, params: SetConfigured) -> Result enum SetMainStatusStatus { Running, Stopped, - Starting, } impl FromStr for SetMainStatusStatus { type Err = color_eyre::eyre::Report; @@ -1009,7 +1001,6 @@ impl FromStr for SetMainStatusStatus { match s { "running" => Ok(Self::Running), "stopped" => Ok(Self::Stopped), - "starting" => Ok(Self::Starting), _ => Err(eyre!("unknown status {s}")), } } @@ -1033,7 +1024,6 @@ async fn set_main_status(context: EffectContext, params: SetMainStatus) -> Resul match params.status { SetMainStatusStatus::Running => context.seed.started(), SetMainStatusStatus::Stopped => context.seed.stopped(), - SetMainStatusStatus::Starting => context.seed.started(), } Ok(Value::Null) } @@ -1262,15 +1252,17 @@ impl ValueParserFactory for DependencyRequirement { #[command(rename_all = "camelCase")] #[ts(export)] struct SetDependenciesParams { + #[serde(default)] + procedure_id: Guid, dependencies: Vec, } async fn set_dependencies( context: EffectContext, - WithProcedureId { + SetDependenciesParams { procedure_id, - rest: SetDependenciesParams { dependencies }, - }: WithProcedureId, + dependencies, + }: SetDependenciesParams, ) -> Result<(), Error> { let context = context.deref()?; let id = &context.seed.id; diff --git a/sdk/lib/mainFn/Daemons.ts b/sdk/lib/mainFn/Daemons.ts index f48dd51c0..059d148ab 100644 --- a/sdk/lib/mainFn/Daemons.ts +++ b/sdk/lib/mainFn/Daemons.ts @@ -168,10 +168,6 @@ export class Daemons { } private updateMainHealth() { - if (this.healthDaemons.every((x) => x.health.status === "success")) { - this.effects.setMainStatus({ status: "running" }) - } else { - this.effects.setMainStatus({ status: "starting" }) - } + this.effects.setMainStatus({ status: "running" }) } } diff --git a/sdk/lib/osBindings/ExecuteAction.ts b/sdk/lib/osBindings/ExecuteAction.ts index abd8c151f..b4eb60949 100644 --- a/sdk/lib/osBindings/ExecuteAction.ts +++ b/sdk/lib/osBindings/ExecuteAction.ts @@ -1,6 +1,8 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Guid } from "./Guid" export type ExecuteAction = { + procedureId: Guid serviceId: string | null actionId: string input: any diff --git a/sdk/lib/osBindings/ProcedureId.ts b/sdk/lib/osBindings/ProcedureId.ts new file mode 100644 index 000000000..4d9a0debd --- /dev/null +++ b/sdk/lib/osBindings/ProcedureId.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Guid } from "./Guid" + +export type ProcedureId = { procedureId: Guid } diff --git a/sdk/lib/osBindings/SetDependenciesParams.ts b/sdk/lib/osBindings/SetDependenciesParams.ts index 7b34b50c9..bbc9b325f 100644 --- a/sdk/lib/osBindings/SetDependenciesParams.ts +++ b/sdk/lib/osBindings/SetDependenciesParams.ts @@ -1,6 +1,8 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { DependencyRequirement } from "./DependencyRequirement" +import type { Guid } from "./Guid" export type SetDependenciesParams = { + procedureId: Guid dependencies: Array } diff --git a/sdk/lib/osBindings/SetMainStatusStatus.ts b/sdk/lib/osBindings/SetMainStatusStatus.ts index 6db32e7bf..03bb4a119 100644 --- a/sdk/lib/osBindings/SetMainStatusStatus.ts +++ b/sdk/lib/osBindings/SetMainStatusStatus.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type SetMainStatusStatus = "running" | "stopped" | "starting" +export type SetMainStatusStatus = "running" | "stopped" diff --git a/sdk/lib/osBindings/index.ts b/sdk/lib/osBindings/index.ts index ac2e19e45..22b03a7ca 100644 --- a/sdk/lib/osBindings/index.ts +++ b/sdk/lib/osBindings/index.ts @@ -108,6 +108,7 @@ export { PackageVersionInfo } from "./PackageVersionInfo" export { ParamsMaybePackageId } from "./ParamsMaybePackageId" export { ParamsPackageId } from "./ParamsPackageId" export { PasswordType } from "./PasswordType" +export { ProcedureId } from "./ProcedureId" export { Progress } from "./Progress" export { Public } from "./Public" export { RecoverySource } from "./RecoverySource"