Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions crates/octos-cli/src/api/auth_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,7 @@ pub async fn me(
let status = if let Some(ref pm) = state.process_manager {
pm.status(&p.id).await
} else {
crate::process_manager::ProcessStatus {
running: false,
pid: None,
started_at: None,
uptime_secs: None,
}
crate::process_manager::ProcessStatus::stopped()
};
Some(ProfileResponse {
email: None,
Expand Down Expand Up @@ -861,12 +856,7 @@ pub async fn me(
let status = if let Some(ref pm) = state.process_manager {
pm.status(&p.id).await
} else {
crate::process_manager::ProcessStatus {
running: false,
pid: None,
started_at: None,
uptime_secs: None,
}
crate::process_manager::ProcessStatus::stopped()
};
Some(ProfileResponse {
email: None,
Expand Down Expand Up @@ -907,12 +897,7 @@ pub async fn my_profile(
let status = if let Some(ref pm) = state.process_manager {
pm.status(&profile.id).await
} else {
crate::process_manager::ProcessStatus {
running: false,
pid: None,
started_at: None,
uptime_secs: None,
}
crate::process_manager::ProcessStatus::stopped()
};

Ok(Json(ProfileResponse {
Expand Down Expand Up @@ -1097,12 +1082,7 @@ pub async fn update_my_profile(
let status = if let Some(ref pm) = state.process_manager {
pm.status(&profile.id).await
} else {
crate::process_manager::ProcessStatus {
running: false,
pid: None,
started_at: None,
uptime_secs: None,
}
crate::process_manager::ProcessStatus::stopped()
};

Ok(Json(ProfileResponse {
Expand Down
22 changes: 21 additions & 1 deletion crates/octos-cli/src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use chrono::{DateTime, Utc};
use serde::Serialize;
use tokio::sync::{Mutex, mpsc};

use crate::process_manager::ProcessManager;
use crate::process_manager::{ProcessManager, ProcessState};
use crate::profiles::ProfileStore;

/// Alert types sent by ProcessManager or health checker.
Expand Down Expand Up @@ -161,6 +161,14 @@ impl Monitor {
// Watchdog: auto-restart on GatewayExited
if let AdminAlert::GatewayExited { ref profile_id, .. } = alert {
if wd1.load(Ordering::Relaxed) {
if pm1.status(profile_id).await.status == ProcessState::ConfigurationError {
tracing::warn!(
profile = %profile_id,
"watchdog skipping restart: profile has configuration error"
);
continue;
}

let mut counts = rc1.lock().await;
let (count, _) =
counts.entry(profile_id.clone()).or_insert((0, Utc::now()));
Expand Down Expand Up @@ -190,6 +198,14 @@ impl Monitor {
let backoff = Duration::from_secs((2u64.pow(attempt)).min(30));
tokio::time::sleep(backoff).await;

if pm1.has_configuration_error(profile_id).await {
tracing::warn!(
profile = %profile_id,
"watchdog skipping restart: profile has configuration error"
);
continue;
}

if let Ok(Some(profile)) = ps1.get(profile_id) {
if let Err(e) = pm1.start(&profile).await {
tracing::warn!(
Expand Down Expand Up @@ -246,6 +262,10 @@ impl Monitor {

for p in &profiles {
if p.enabled && !statuses.contains_key(&p.id) {
if pm.status(&p.id).await.status == ProcessState::ConfigurationError {
continue;
}

// Check if watchdog already knows about this
let counts = rc2.lock().await;
let already_tracked = counts.get(&p.id).is_some_and(|(c, _)| *c > 0);
Expand Down
Loading
Loading