rebuild button on agent UI (cross-origin POST to dashboard /rebuild)
This commit is contained in:
parent
824914807a
commit
f1fd787f17
7 changed files with 42 additions and 6 deletions
|
|
@ -101,10 +101,11 @@ pub async fn spawn(
|
|||
proposed_dir: &Path,
|
||||
applied_dir: &Path,
|
||||
claude_dir: &Path,
|
||||
dashboard_port: u16,
|
||||
) -> Result<()> {
|
||||
validate(name)?;
|
||||
setup_proposed(proposed_dir, name).await?;
|
||||
setup_applied(applied_dir, name, hyperhive_flake).await?;
|
||||
setup_applied(applied_dir, name, hyperhive_flake, dashboard_port).await?;
|
||||
ensure_claude_dir(claude_dir)?;
|
||||
let container = container_name(name);
|
||||
let flake_ref = format!("{}#default", applied_dir.display());
|
||||
|
|
@ -145,9 +146,10 @@ pub async fn rebuild(
|
|||
agent_dir: &Path,
|
||||
applied_dir: &Path,
|
||||
claude_dir: &Path,
|
||||
dashboard_port: u16,
|
||||
) -> Result<()> {
|
||||
validate(name)?;
|
||||
setup_applied(applied_dir, name, hyperhive_flake).await?;
|
||||
setup_applied(applied_dir, name, hyperhive_flake, dashboard_port).await?;
|
||||
ensure_claude_dir(claude_dir)?;
|
||||
let container = container_name(name);
|
||||
let flake_ref = format!("{}#default", applied_dir.display());
|
||||
|
|
@ -205,7 +207,12 @@ pub async fn setup_proposed(proposed_dir: &Path, name: &str) -> Result<()> {
|
|||
/// Maintain the authoritative applied repo. Rewrites `flake.nix` every call
|
||||
/// (so a new hyperhive flake URL propagates on rebuild); seeds `agent.nix`
|
||||
/// only on first call. `apply_commit` overwrites `agent.nix` later.
|
||||
pub async fn setup_applied(applied_dir: &Path, name: &str, hyperhive_flake: &str) -> Result<()> {
|
||||
pub async fn setup_applied(
|
||||
applied_dir: &Path,
|
||||
name: &str,
|
||||
hyperhive_flake: &str,
|
||||
dashboard_port: u16,
|
||||
) -> Result<()> {
|
||||
std::fs::create_dir_all(applied_dir)
|
||||
.with_context(|| format!("create {}", applied_dir.display()))?;
|
||||
|
||||
|
|
@ -242,6 +249,7 @@ pub async fn setup_applied(applied_dir: &Path, name: &str, hyperhive_flake: &str
|
|||
systemd.services.{service}.environment = {{
|
||||
HIVE_PORT = "{port}";
|
||||
HIVE_LABEL = "{name}";
|
||||
HIVE_DASHBOARD_PORT = "{dashboard_port}";
|
||||
}};
|
||||
}}
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue