Shutdown logic & Panel

This commit is contained in:
Alex Emmet 2025-11-25 18:37:13 +00:00
commit 0ec6159365
7 changed files with 46 additions and 2 deletions

View file

@ -1,5 +1,6 @@
use std::sync::Arc;
use crate::SHUTDOWN;
use crate::auth::auth_connector::unregister_user;
use crate::communities::community::Community;
use crate::data::communication::{CommunicationType, CommunicationValue, DataTypes};
@ -39,6 +40,14 @@ pub async fn handle(
};
let (status, content, body_text) = if path_parts.len() >= 3 {
match path_parts[2] {
"shutdown" => {
*SHUTDOWN.write().await = true;
(
StatusCode::OK,
"application/json",
"{\"type\":\"success\"}".to_string(),
)
}
"app_state" => (StatusCode::OK, "application/json", {
let with = headers
.get("size")

View file

@ -1,3 +1,4 @@
use crate::SHUTDOWN;
use crate::gui::log_panel::log_message;
use crate::server::api;
use crate::server::socket::handle;
@ -233,6 +234,9 @@ async fn run_http_server(port: u16) -> bool {
tokio::spawn(async move {
loop {
if *SHUTDOWN.read().await {
break;
}
match listener.accept().await {
std::result::Result::Ok((stream, addr)) => {
let service = HttpService { peer_addr: addr };
@ -287,6 +291,9 @@ async fn run_tls_server(port: u16, tls_config: Arc<ServerConfig>) -> bool {
tokio::spawn(async move {
loop {
if *SHUTDOWN.read().await {
break;
}
match listener.accept().await {
std::result::Result::Ok((stream, addr)) => {
let service = HttpService { peer_addr: addr };

View file

@ -1,3 +1,4 @@
use crate::SHUTDOWN;
use crate::communities::{community_connection::CommunityConnection, community_manager};
use crate::gui::log_panel::log_message;
use crate::omikron::omikron_connection::OmikronConnection;
@ -26,6 +27,9 @@ pub fn handle(
let community_conn: Arc<CommunityConnection> =
Arc::from(CommunityConnection::new(writer, reader, community));
loop {
if *SHUTDOWN.read().await {
break;
}
let msg_result = {
let mut session_lock = community_conn.receiver.write().await;
session_lock.next().await