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 {
|
match data.startup {
|
||||||
true => {
|
true => {
|
||||||
debug!("Enabling go-sbot.service");
|
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)
|
warn!("Failed to enable go-sbot.service: {}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false => {
|
false => {
|
||||||
debug!("Disabling go-sbot.service");
|
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)
|
warn!("Failed to disable go-sbot.service: {}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use log::info;
|
use log::info;
|
||||||
use rouille::Response;
|
use rouille::Response;
|
||||||
|
|
||||||
use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
use crate::utils::{flash::FlashResponse, sbot};
|
||||||
|
|
||||||
// ROUTE: /settings/scuttlebutt/restart
|
// ROUTE: /settings/scuttlebutt/restart
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
||||||
/// the attempt via a flash message.
|
/// the attempt via a flash message.
|
||||||
pub fn restart_sbot() -> Response {
|
pub fn restart_sbot() -> Response {
|
||||||
info!("Restarting go-sbot.service");
|
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
|
// if stop was successful, try to start the process
|
||||||
Ok(_) => match systemctl_sbot_cmd("start") {
|
Ok(_) => match sbot::system_sbot_cmd("start") {
|
||||||
Ok(_) => (
|
Ok(_) => (
|
||||||
"flash_name=success".to_string(),
|
"flash_name=success".to_string(),
|
||||||
"flash_msg=Sbot process has been restarted".to_string(),
|
"flash_msg=Sbot process has been restarted".to_string(),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use log::info;
|
use log::info;
|
||||||
use rouille::Response;
|
use rouille::Response;
|
||||||
|
|
||||||
use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
use crate::utils::{flash::FlashResponse, sbot};
|
||||||
|
|
||||||
// ROUTE: /settings/scuttlebutt/start
|
// ROUTE: /settings/scuttlebutt/start
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
||||||
/// the attempt via a flash message.
|
/// the attempt via a flash message.
|
||||||
pub fn start_sbot() -> Response {
|
pub fn start_sbot() -> Response {
|
||||||
info!("Starting go-sbot.service");
|
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(_) => (
|
Ok(_) => (
|
||||||
"flash_name=success".to_string(),
|
"flash_name=success".to_string(),
|
||||||
"flash_msg=Sbot process has been started".to_string(),
|
"flash_msg=Sbot process has been started".to_string(),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use log::info;
|
use log::info;
|
||||||
use rouille::Response;
|
use rouille::Response;
|
||||||
|
|
||||||
use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
use crate::utils::{flash::FlashResponse, sbot};
|
||||||
|
|
||||||
// ROUTE: /settings/scuttlebutt/stop
|
// ROUTE: /settings/scuttlebutt/stop
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ use crate::utils::{flash::FlashResponse, sbot::systemctl_sbot_cmd};
|
||||||
/// the attempt via a flash message.
|
/// the attempt via a flash message.
|
||||||
pub fn stop_sbot() -> Response {
|
pub fn stop_sbot() -> Response {
|
||||||
info!("Stopping go-sbot.service");
|
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(_) => (
|
Ok(_) => (
|
||||||
"flash_name=success".to_string(),
|
"flash_name=success".to_string(),
|
||||||
"flash_msg=Sbot process has been stopped".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")?)
|
.arg(config_manager::get_config_value("GO_SBOT_SERVICE")?)
|
||||||
.output()?;
|
.output()?;
|
||||||
Ok(output)
|
Ok(output)
|
||||||
},
|
}
|
||||||
"supervisord" => {
|
"supervisord" => {
|
||||||
match cmd {
|
match cmd {
|
||||||
"enable" => {
|
"enable" => {
|
||||||
// TODO: implement this
|
// TODO: implement this
|
||||||
},
|
let output = Command::new("echo")
|
||||||
|
.arg("implement this (enable)")
|
||||||
|
.output()?;
|
||||||
|
Ok(output)
|
||||||
|
}
|
||||||
"disable" => {
|
"disable" => {
|
||||||
// TODO: implement this
|
let output = Command::new("echo")
|
||||||
},
|
.arg("implement this (disable)")
|
||||||
|
.output()?;
|
||||||
|
Ok(output)
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let output = Command::new("supervisorctl")
|
let output = Command::new("supervisorctl")
|
||||||
.arg(cmd)
|
.arg(cmd)
|
||||||
|
@ -54,10 +61,11 @@ pub fn system_sbot_cmd(cmd: &str) -> Result<Output, PeachWebError> {
|
||||||
Ok(output)
|
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