2022-03-20 14:38:32 +00:00
|
|
|
use log::info;
|
|
|
|
use rouille::Response;
|
|
|
|
|
2022-07-27 17:03:36 +00:00
|
|
|
use crate::utils::{flash::FlashResponse, sbot};
|
2022-03-20 14:38:32 +00:00
|
|
|
|
|
|
|
// ROUTE: /settings/scuttlebutt/start
|
|
|
|
|
|
|
|
/// Attempt to start the go-sbot.service process.
|
|
|
|
/// Redirect to the Scuttlebutt settings menu and communicate the outcome of
|
|
|
|
/// the attempt via a flash message.
|
|
|
|
pub fn start_sbot() -> Response {
|
|
|
|
info!("Starting go-sbot.service");
|
2022-07-27 17:03:36 +00:00
|
|
|
let (flash_name, flash_msg) = match sbot::system_sbot_cmd("start") {
|
2022-03-20 14:38:32 +00:00
|
|
|
Ok(_) => (
|
|
|
|
"flash_name=success".to_string(),
|
|
|
|
"flash_msg=Sbot process has been started".to_string(),
|
|
|
|
),
|
|
|
|
Err(_) => (
|
|
|
|
"flash_name=error".to_string(),
|
|
|
|
"flash_msg=Failed to start the sbot process".to_string(),
|
|
|
|
),
|
|
|
|
};
|
|
|
|
|
|
|
|
// redirect to the scuttlebutt settings menu
|
|
|
|
Response::redirect_303("/settings/scuttlebutt").add_flash(flash_name, flash_msg)
|
|
|
|
}
|