aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-20 12:50:02 -0700
committerFuwn <[email protected]>2021-05-20 12:50:02 -0700
commitef443e262c5686e20e36b6e24c555cab41a47669 (patch)
treef3f053c4413e0d80f53afa1395008bb98b9f0ed3
parentrefactor(whirl_server): cut down on the clones (diff)
downloadwhirl-ef443e262c5686e20e36b6e24c555cab41a47669.tar.xz
whirl-ef443e262c5686e20e36b6e24c555cab41a47669.zip
feat(whirl_server): development testing environment variable
Useful when debugging certain session exit bugs. Make sure to use the `runw` task!
-rw-r--r--Makefile.toml1
-rw-r--r--whirl_server/src/lib.rs6
2 files changed, 7 insertions, 0 deletions
diff --git a/Makefile.toml b/Makefile.toml
index 7f1882f..ebb302b 100644
--- a/Makefile.toml
+++ b/Makefile.toml
@@ -3,6 +3,7 @@
# -------------
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
+EXIT_ON_CLIENT_DISCONNECT = true
# This variable will vary depending on where you installed Worlds, ideally, you
# should know the correct value for your own system.
diff --git a/whirl_server/src/lib.rs b/whirl_server/src/lib.rs
index 12080cd..9c3e9d0 100644
--- a/whirl_server/src/lib.rs
+++ b/whirl_server/src/lib.rs
@@ -71,6 +71,12 @@ pub trait Server {
if let Err(e) = Self::handle(state, stream, address, counter).await {
error!("an error occurred: {}", e);
}
+
+ if std::env::var("EXIT_ON_CLIENT_DISCONNECT").unwrap_or_else(|_| "false".to_string())
+ == "true"
+ {
+ std::process::exit(0);
+ }
});
}
}