fixup after rebase

This commit is contained in:
Aiden McClelland
2023-03-09 15:02:09 -07:00
parent 5e9e26fa67
commit 18922a1c6d
24 changed files with 40 additions and 779 deletions

View File

@@ -12,7 +12,6 @@ use sqlx::Acquire;
use crate::{
config::hook::ConfigHook,
manager::{start_stop::StartStop, Manager},
net::keys::Key,
};
use super::try_get_running_ip;
@@ -165,26 +164,29 @@ impl OsApi for Manager {
Ok(())
}
fn set_started(&self) {
fn set_started(&self) -> Result<(), Report> {
self.manage_container
.current_state
.send(StartStop::Start)
.unwrap_or_default()
.send_modify(|x| *x = StartStop::Start);
Ok(())
}
async fn restart(&self) {
self.perform_restart().await
async fn restart(&self) -> Result<(), Report> {
self.perform_restart().await;
Ok(())
}
async fn start(&self) {
async fn start(&self) -> Result<(), Report> {
self.manage_container
.wait_for_desired(StartStop::Start)
.await
.await;
Ok(())
}
async fn stop(&self) {
async fn stop(&self) -> Result<(), Report> {
self.manage_container
.wait_for_desired(StartStop::Stop)
.await
.await;
Ok(())
}
}

View File

@@ -75,9 +75,9 @@ impl ManageContainer {
}
pub async fn wait_for_desired(&self, new_state: StartStop) {
let current_state = self.current_state();
let mut current_state = self.current_state();
self.to_desired(new_state);
while current_state.borrow() != new_state {
while *current_state.borrow() != new_state {
current_state.changed().await.unwrap_or_default();
}
}

View File

@@ -14,7 +14,6 @@ use nix::sys::signal::Signal;
use patch_db::DbHandle;
use persistent_container::PersistentContainer;
use rand::SeedableRng;
use serde_json::Value;
use sqlx::Connection;
use start_stop::StartStop;
use tokio::sync::oneshot;

View File

@@ -52,7 +52,6 @@ pub async fn spawn_persistent_container(
let mut send_inserter: Option<oneshot::Sender<Receiver<Arc<UnixRpcClient>>>> = Some(send_inserter);
loop {
if let Err(e) = async {
let generated_certificate = generate_certificate(&*seed).await?;
let (mut runtime, inserter) =
long_running_docker(&seed, &container).await?;

View File

@@ -20,7 +20,7 @@ impl From<MainStatus> for StartStop {
MainStatus::Stopped => StartStop::Stop,
MainStatus::Restarting => StartStop::Start,
MainStatus::Stopping => StartStop::Stop,
MainStatus::Starting { restarting } => StartStop::Start,
MainStatus::Starting => StartStop::Start,
MainStatus::Running { started, health } => StartStop::Start,
MainStatus::BackingUp { started, health } if started.is_some() => StartStop::Start,
MainStatus::BackingUp { started, health } => StartStop::Stop,