single-user service manager
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889use crate::apogee_core_v1;use anyhow::Context;use bevy_ecs::prelude::*;use serde::Deserialize;use std::collections::BTreeMap;use std::{path, sync};
#[derive(Deserialize, Debug)]pub struct Service { pub name: sync::Arc<str>, #[serde(default)] pub description: String, pub command: String, #[serde(default)] pub args: Vec<String>, #[serde(default)] pub conditions: Vec<Condition>, pub ready: Condition, pub running: Condition, #[serde(default)] pub env: BTreeMap<String, String>, pub restart: Restart, #[serde(default)] pub notify: Notify,}
#[derive(Deserialize, Debug)]pub struct Task { pub name: sync::Arc<str>, #[serde(default)] pub description: String, pub command: String, #[serde(default)] pub args: Vec<String>, #[serde(default)] pub conditions: Vec<Condition>, pub running: Condition, pub successful: Condition, #[serde(default)] pub env: BTreeMap<String, String>,}
#[derive(Component, Deserialize, Debug, Default, PartialEq, Eq)]pub enum Notify { #[default] None, Systemd, S6,}
#[derive(Deserialize, Debug)]pub struct Condition { pub name: sync::Arc<str>, pub immutable: bool,}
#[derive(Deserialize, Debug)]pub struct Configuration { #[serde(default)] pub conditions: Vec<Condition>, #[serde(default)] pub services: Vec<Service>, #[serde(default)] pub tasks: Vec<Task>,}
#[derive(Deserialize, Resource)]pub struct Config(pub path::PathBuf);
#[derive(Deserialize, Debug)]pub struct Restart { pub on: apogee_core_v1::RestartPolicy, #[serde(default = "default_restart_delay")] pub delay: u64,}
const fn default_restart_delay() -> u64 { 5}
impl Config { pub fn load(&self) -> anyhow::Result<Configuration> { serde_dhall::from_file(&self.0) .imports(true) .parse::<Configuration>() .context("evaluating Dhall config") }}