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