peach-workspace/peach-web/src/routes/settings/scuttlebutt/stop.rs

27 lines
864 B
Rust

use log::info;
use rouille::Response;
use crate::utils::{flash::FlashResponse, sbot};
// ROUTE: /settings/scuttlebutt/stop
/// Attempt to stop the go-sbot.service process.
/// Redirect to the Scuttlebutt settings menu and communicate the outcome of
/// the attempt via a flash message.
pub fn stop_sbot() -> Response {
info!("Stopping go-sbot.service");
let (flash_name, flash_msg) = match sbot::system_sbot_cmd("stop") {
Ok(_) => (
"flash_name=success".to_string(),
"flash_msg=Sbot process has been stopped".to_string(),
),
Err(_) => (
"flash_name=error".to_string(),
"flash_msg=Failed to stop the sbot process".to_string(),
),
};
// redirect to the scuttlebutt settings menu
Response::redirect_303("/settings/scuttlebutt").add_flash(flash_name, flash_msg)
}