mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +00:00
@@ -64,56 +64,6 @@ impl EffectContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct WithProcedureId<T> {
|
|
||||||
#[serde(default)]
|
|
||||||
procedure_id: Guid,
|
|
||||||
#[serde(flatten)]
|
|
||||||
rest: T,
|
|
||||||
}
|
|
||||||
impl<T: FromArgMatches> FromArgMatches for WithProcedureId<T> {
|
|
||||||
fn from_arg_matches(matches: &clap::ArgMatches) -> Result<Self, clap::Error> {
|
|
||||||
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<Self, clap::Error> {
|
|
||||||
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<T: CommandFactory> CommandFactory for WithProcedureId<T> {
|
|
||||||
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<C: Context>() -> ParentHandler<C> {
|
pub fn service_effect_handler<C: Context>() -> ParentHandler<C> {
|
||||||
ParentHandler::new()
|
ParentHandler::new()
|
||||||
.subcommand("gitInfo", from_fn(|_: C| crate::version::git_info()))
|
.subcommand("gitInfo", from_fn(|_: C| crate::version::git_info()))
|
||||||
@@ -877,6 +827,8 @@ async fn exists(context: EffectContext, params: ParamsPackageId) -> Result<Value
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
struct ExecuteAction {
|
struct ExecuteAction {
|
||||||
|
#[serde(default)]
|
||||||
|
procedure_id: Guid,
|
||||||
#[ts(type = "string | null")]
|
#[ts(type = "string | null")]
|
||||||
service_id: Option<PackageId>,
|
service_id: Option<PackageId>,
|
||||||
#[ts(type = "string")]
|
#[ts(type = "string")]
|
||||||
@@ -886,15 +838,12 @@ struct ExecuteAction {
|
|||||||
}
|
}
|
||||||
async fn execute_action(
|
async fn execute_action(
|
||||||
context: EffectContext,
|
context: EffectContext,
|
||||||
WithProcedureId {
|
ExecuteAction {
|
||||||
procedure_id,
|
procedure_id,
|
||||||
rest:
|
service_id,
|
||||||
ExecuteAction {
|
action_id,
|
||||||
service_id,
|
input,
|
||||||
action_id,
|
}: ExecuteAction,
|
||||||
input,
|
|
||||||
},
|
|
||||||
}: WithProcedureId<ExecuteAction>,
|
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
let context = context.deref()?;
|
let context = context.deref()?;
|
||||||
let package_id = service_id
|
let package_id = service_id
|
||||||
@@ -950,9 +899,53 @@ async fn running(context: EffectContext, params: ParamsPackageId) -> Result<Valu
|
|||||||
Ok(json!(matches!(package, MainStatus::Running { .. })))
|
Ok(json!(matches!(package, MainStatus::Running { .. })))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
struct ProcedureId {
|
||||||
|
#[serde(default)]
|
||||||
|
procedure_id: Guid,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromArgMatches for ProcedureId {
|
||||||
|
fn from_arg_matches(matches: &clap::ArgMatches) -> Result<Self, clap::Error> {
|
||||||
|
Ok(Self {
|
||||||
|
procedure_id: matches.get_one("procedure-id").cloned().unwrap_or_default(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fn from_arg_matches_mut(matches: &mut clap::ArgMatches) -> Result<Self, clap::Error> {
|
||||||
|
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(
|
async fn restart(
|
||||||
context: EffectContext,
|
context: EffectContext,
|
||||||
WithProcedureId { procedure_id, .. }: WithProcedureId<Empty>,
|
ProcedureId { procedure_id }: ProcedureId,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let context = context.deref()?;
|
let context = context.deref()?;
|
||||||
context.restart(procedure_id).await?;
|
context.restart(procedure_id).await?;
|
||||||
@@ -961,7 +954,7 @@ async fn restart(
|
|||||||
|
|
||||||
async fn shutdown(
|
async fn shutdown(
|
||||||
context: EffectContext,
|
context: EffectContext,
|
||||||
WithProcedureId { procedure_id, .. }: WithProcedureId<Empty>,
|
ProcedureId { procedure_id }: ProcedureId,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let context = context.deref()?;
|
let context = context.deref()?;
|
||||||
context.stop(procedure_id).await?;
|
context.stop(procedure_id).await?;
|
||||||
@@ -1001,7 +994,6 @@ async fn set_configured(context: EffectContext, params: SetConfigured) -> Result
|
|||||||
enum SetMainStatusStatus {
|
enum SetMainStatusStatus {
|
||||||
Running,
|
Running,
|
||||||
Stopped,
|
Stopped,
|
||||||
Starting,
|
|
||||||
}
|
}
|
||||||
impl FromStr for SetMainStatusStatus {
|
impl FromStr for SetMainStatusStatus {
|
||||||
type Err = color_eyre::eyre::Report;
|
type Err = color_eyre::eyre::Report;
|
||||||
@@ -1009,7 +1001,6 @@ impl FromStr for SetMainStatusStatus {
|
|||||||
match s {
|
match s {
|
||||||
"running" => Ok(Self::Running),
|
"running" => Ok(Self::Running),
|
||||||
"stopped" => Ok(Self::Stopped),
|
"stopped" => Ok(Self::Stopped),
|
||||||
"starting" => Ok(Self::Starting),
|
|
||||||
_ => Err(eyre!("unknown status {s}")),
|
_ => Err(eyre!("unknown status {s}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1033,7 +1024,6 @@ async fn set_main_status(context: EffectContext, params: SetMainStatus) -> Resul
|
|||||||
match params.status {
|
match params.status {
|
||||||
SetMainStatusStatus::Running => context.seed.started(),
|
SetMainStatusStatus::Running => context.seed.started(),
|
||||||
SetMainStatusStatus::Stopped => context.seed.stopped(),
|
SetMainStatusStatus::Stopped => context.seed.stopped(),
|
||||||
SetMainStatusStatus::Starting => context.seed.started(),
|
|
||||||
}
|
}
|
||||||
Ok(Value::Null)
|
Ok(Value::Null)
|
||||||
}
|
}
|
||||||
@@ -1262,15 +1252,17 @@ impl ValueParserFactory for DependencyRequirement {
|
|||||||
#[command(rename_all = "camelCase")]
|
#[command(rename_all = "camelCase")]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
struct SetDependenciesParams {
|
struct SetDependenciesParams {
|
||||||
|
#[serde(default)]
|
||||||
|
procedure_id: Guid,
|
||||||
dependencies: Vec<DependencyRequirement>,
|
dependencies: Vec<DependencyRequirement>,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn set_dependencies(
|
async fn set_dependencies(
|
||||||
context: EffectContext,
|
context: EffectContext,
|
||||||
WithProcedureId {
|
SetDependenciesParams {
|
||||||
procedure_id,
|
procedure_id,
|
||||||
rest: SetDependenciesParams { dependencies },
|
dependencies,
|
||||||
}: WithProcedureId<SetDependenciesParams>,
|
}: SetDependenciesParams,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let context = context.deref()?;
|
let context = context.deref()?;
|
||||||
let id = &context.seed.id;
|
let id = &context.seed.id;
|
||||||
|
|||||||
@@ -168,10 +168,6 @@ export class Daemons<Manifest extends SDKManifest, Ids extends string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateMainHealth() {
|
private updateMainHealth() {
|
||||||
if (this.healthDaemons.every((x) => x.health.status === "success")) {
|
this.effects.setMainStatus({ status: "running" })
|
||||||
this.effects.setMainStatus({ status: "running" })
|
|
||||||
} else {
|
|
||||||
this.effects.setMainStatus({ status: "starting" })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// 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 = {
|
export type ExecuteAction = {
|
||||||
|
procedureId: Guid
|
||||||
serviceId: string | null
|
serviceId: string | null
|
||||||
actionId: string
|
actionId: string
|
||||||
input: any
|
input: any
|
||||||
|
|||||||
4
sdk/lib/osBindings/ProcedureId.ts
Normal file
4
sdk/lib/osBindings/ProcedureId.ts
Normal file
@@ -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 }
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// 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 { DependencyRequirement } from "./DependencyRequirement"
|
||||||
|
import type { Guid } from "./Guid"
|
||||||
|
|
||||||
export type SetDependenciesParams = {
|
export type SetDependenciesParams = {
|
||||||
|
procedureId: Guid
|
||||||
dependencies: Array<DependencyRequirement>
|
dependencies: Array<DependencyRequirement>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// 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"
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ export { PackageVersionInfo } from "./PackageVersionInfo"
|
|||||||
export { ParamsMaybePackageId } from "./ParamsMaybePackageId"
|
export { ParamsMaybePackageId } from "./ParamsMaybePackageId"
|
||||||
export { ParamsPackageId } from "./ParamsPackageId"
|
export { ParamsPackageId } from "./ParamsPackageId"
|
||||||
export { PasswordType } from "./PasswordType"
|
export { PasswordType } from "./PasswordType"
|
||||||
|
export { ProcedureId } from "./ProcedureId"
|
||||||
export { Progress } from "./Progress"
|
export { Progress } from "./Progress"
|
||||||
export { Public } from "./Public"
|
export { Public } from "./Public"
|
||||||
export { RecoverySource } from "./RecoverySource"
|
export { RecoverySource } from "./RecoverySource"
|
||||||
|
|||||||
Reference in New Issue
Block a user