Fix supervisorctl
This commit is contained in:
parent
ceb7e502ce
commit
b24fb387b9
|
@ -243,13 +243,13 @@ pub fn handle_form(request: &Request, restart: bool) -> Response {
|
|||
match data.startup {
|
||||
true => {
|
||||
debug!("Enabling go-sbot.service");
|
||||
if let Err(e) = sbot::systemctl_sbot_cmd("enable") {
|
||||
if let Err(e) = sbot::system_sbot_cmd("enable") {
|
||||
warn!("Failed to enable go-sbot.service: {}", e)
|
||||
}
|
||||
}
|
||||
false => {
|
||||
debug!("Disabling go-sbot.service");
|
||||
if let Err(e) = sbot::systemctl_sbot_cmd("disable") {
|
||||
if let Err(e) = sbot::system_sbot_cmd("disable") {
|
||||
warn!("Failed to disable go-sbot.service: {}", e)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use log::info;
|
||||
use rouille::Response;
|
||||
|
||||
use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
||||
use crate::utils::{flash::FlashResponse, sbot};
|
||||
|
||||
// ROUTE: /settings/scuttlebutt/restart
|
||||
|
||||
|
@ -10,9 +10,9 @@ use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
|||
/// the attempt via a flash message.
|
||||
pub fn restart_sbot() -> Response {
|
||||
info!("Restarting go-sbot.service");
|
||||
let (flash_name, flash_msg) = match systemctl_sbot_cmd("stop") {
|
||||
let (flash_name, flash_msg) = match sbot::system_sbot_cmd("stop") {
|
||||
// if stop was successful, try to start the process
|
||||
Ok(_) => match systemctl_sbot_cmd("start") {
|
||||
Ok(_) => match sbot::system_sbot_cmd("start") {
|
||||
Ok(_) => (
|
||||
"flash_name=success".to_string(),
|
||||
"flash_msg=Sbot process has been restarted".to_string(),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use log::info;
|
||||
use rouille::Response;
|
||||
|
||||
use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
||||
use crate::utils::{flash::FlashResponse, sbot};
|
||||
|
||||
// ROUTE: /settings/scuttlebutt/start
|
||||
|
||||
|
@ -10,7 +10,7 @@ use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
|||
/// the attempt via a flash message.
|
||||
pub fn start_sbot() -> Response {
|
||||
info!("Starting go-sbot.service");
|
||||
let (flash_name, flash_msg) = match systemctl_sbot_cmd("start") {
|
||||
let (flash_name, flash_msg) = match sbot::system_sbot_cmd("start") {
|
||||
Ok(_) => (
|
||||
"flash_name=success".to_string(),
|
||||
"flash_msg=Sbot process has been started".to_string(),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use log::info;
|
||||
use rouille::Response;
|
||||
|
||||
use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
||||
use crate::utils::{flash::FlashResponse, sbot};
|
||||
|
||||
// ROUTE: /settings/scuttlebutt/stop
|
||||
|
||||
|
@ -10,7 +10,7 @@ use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
|||
/// the attempt via a flash message.
|
||||
pub fn stop_sbot() -> Response {
|
||||
info!("Stopping go-sbot.service");
|
||||
let (flash_name, flash_msg) = match systemctl_sbot_cmd("stop") {
|
||||
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(),
|
||||
|
|
|
@ -37,15 +37,22 @@ pub fn system_sbot_cmd(cmd: &str) -> Result<Output, PeachWebError> {
|
|||
.arg(config_manager::get_config_value("GO_SBOT_SERVICE")?)
|
||||
.output()?;
|
||||
Ok(output)
|
||||
},
|
||||
}
|
||||
"supervisord" => {
|
||||
match cmd {
|
||||
"enable" => {
|
||||
// TODO: implement this
|
||||
},
|
||||
let output = Command::new("echo")
|
||||
.arg("implement this (enable)")
|
||||
.output()?;
|
||||
Ok(output)
|
||||
}
|
||||
"disable" => {
|
||||
// TODO: implement this
|
||||
},
|
||||
let output = Command::new("echo")
|
||||
.arg("implement this (disable)")
|
||||
.output()?;
|
||||
Ok(output)
|
||||
}
|
||||
_ => {
|
||||
let output = Command::new("supervisorctl")
|
||||
.arg(cmd)
|
||||
|
@ -54,10 +61,11 @@ pub fn system_sbot_cmd(cmd: &str) -> Result<Output, PeachWebError> {
|
|||
Ok(output)
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
PeachWebError::System(format!("Invalid configuration for SYSTEM_MANAGER: {:?}", system_manager))
|
||||
}
|
||||
_ => Err(PeachWebError::System(format!(
|
||||
"Invalid configuration for SYSTEM_MANAGER: {:?}",
|
||||
system_manager
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue