Feature/restart service (#1554)

* add restart button to service show page and restart rpc api

* Feature/restart rpc (#1555)

* add restart rpc and status

* wire up rpc

* add restarting bool

Co-authored-by: Aiden McClelland <me@drbonez.dev>

* check if service is restarting

* filter package when restarting to avoid glitch

Co-authored-by: Aiden McClelland <me@drbonez.dev>
This commit is contained in:
Lucy C
2022-06-17 20:11:15 -06:00
parent 889cf03c1c
commit a4a8f33df0
18 changed files with 212 additions and 64 deletions

View File

@@ -24,8 +24,11 @@ pub struct Status {
#[serde(rename_all = "kebab-case")]
pub enum MainStatus {
Stopped,
Restarting,
Stopping,
Starting,
Starting {
restarting: bool,
},
Running {
started: DateTime<Utc>,
health: BTreeMap<HealthCheckId, HealthCheckResult>,
@@ -38,25 +41,26 @@ pub enum MainStatus {
impl MainStatus {
pub fn running(&self) -> bool {
match self {
MainStatus::Starting
MainStatus::Starting { .. }
| MainStatus::Running { .. }
| MainStatus::BackingUp {
started: Some(_), ..
} => true,
MainStatus::Stopped
| MainStatus::Stopping
| MainStatus::Restarting
| MainStatus::BackingUp { started: None, .. } => false,
}
}
pub fn stop(&mut self) {
match self {
MainStatus::Starting | MainStatus::Running { .. } => {
MainStatus::Starting { .. } | MainStatus::Running { .. } => {
*self = MainStatus::Stopping;
}
MainStatus::BackingUp { started, .. } => {
*started = None;
}
MainStatus::Stopped | MainStatus::Stopping => (),
MainStatus::Stopped | MainStatus::Stopping | MainStatus::Restarting => (),
}
}
}