fixed restarts and long status messages
parent
6a1682be63
commit
de71b5124c
|
@ -249,9 +249,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.34"
|
||||
version = "0.4.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b"
|
||||
checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
|
@ -406,7 +406,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "daemon"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"config",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "daemon"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -290,17 +290,27 @@ async fn service(
|
|||
.await?;
|
||||
}
|
||||
ServiceAction::Restart => {
|
||||
systemctl::stop(&service_name)?;
|
||||
systemctl::restart(&service_name)?;
|
||||
ctx.reply(format!("`{}` has been restarted", service_name))
|
||||
.await?;
|
||||
}
|
||||
ServiceAction::Status => {
|
||||
let status = systemctl::status(&service.name)?;
|
||||
let mut msg = MessageBuilder::new();
|
||||
|
||||
msg.push_codeblock_safe(status, None);
|
||||
if status.len() > serenity::MESSAGE_CODE_LIMIT {
|
||||
let file_name = format!("{}_status.log", service_name);
|
||||
ctx.send(
|
||||
CreateReply::default()
|
||||
.attachment(CreateAttachment::bytes(status.into_bytes(), &file_name)),
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
let mut msg = MessageBuilder::new();
|
||||
|
||||
ctx.reply(msg.build()).await?;
|
||||
msg.push_codeblock_safe(status, None);
|
||||
|
||||
ctx.reply(msg.build()).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue