aboutsummaryrefslogtreecommitdiff
path: root/src/handlers
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-06-09 15:20:17 -0400
committerCara Salter <cara@devcara.com>2022-06-09 15:20:17 -0400
commitf64edeb631bfdefcd757483d7dfbe204daabf1ab (patch)
tree8bb4e505c2de62cdaecbb134733e2dbb3ea218cc /src/handlers
parent03989d646ee3fd74536d420860e9f5bcf58937af (diff)
downloadsolard-f64edeb631bfdefcd757483d7dfbe204daabf1ab.tar.gz
solard-f64edeb631bfdefcd757483d7dfbe204daabf1ab.zip
state: Force reboot/shutdown
Closes #1
Diffstat (limited to 'src/handlers')
-rw-r--r--src/handlers/planets.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/handlers/planets.rs b/src/handlers/planets.rs
index ede7b2b..06773bc 100644
--- a/src/handlers/planets.rs
+++ b/src/handlers/planets.rs
@@ -76,3 +76,27 @@ pub async fn reboot(Path(uuid): Path<String>) -> NoneResult {
Ok(())
}
+
+pub async fn force_reboot(Path(uuid): Path<String>) -> NoneResult {
+ let mut s = get_star()?;
+
+ if let Ok(p) = s.find_planet(uuid) {
+ p.hard_reboot()?;
+ } else {
+ return Err(ServiceError::NotFound);
+ }
+
+ Ok(())
+}
+
+pub async fn force_shutdown(Path(uuid): Path<String>) -> NoneResult {
+ let mut s = get_star()?;
+
+ if let Ok(p) = s.find_planet(uuid) {
+ p.hard_shutdown()?;
+ } else {
+ return Err(ServiceError::NotFound);
+ }
+
+ Ok(())
+}