mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-15 05:06:53 +00:00
add server restart support w/ admin command
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
1 parent
2cb31275f0
commit
c6f4b20e17
5 files changed
+54
-2
No files matched your search
@@ -23,6 +23,9 @@ pub struct Server {
|
||||
/// is an observable used on shutdown and modifying is not recommended.
|
||||
pub reloading: AtomicBool,
|
||||
|
||||
/// Restart desired; when true, restart it desired after shutdown.
|
||||
pub restarting: AtomicBool,
|
||||
|
||||
/// Handle to the runtime
|
||||
pub runtime: Option<runtime::Handle>,
|
||||
|
||||
@@ -48,6 +51,7 @@ impl Server {
|
||||
started: SystemTime::now(),
|
||||
stopping: AtomicBool::new(false),
|
||||
reloading: AtomicBool::new(false),
|
||||
restarting: AtomicBool::new(false),
|
||||
runtime,
|
||||
signal: broadcast::channel::<&'static str>(1).0,
|
||||
log,
|
||||
@@ -75,6 +79,14 @@ impl Server {
|
||||
self.signal("SIGINT")
|
||||
}
|
||||
|
||||
pub fn restart(&self) -> Result<()> {
|
||||
if self.restarting.swap(true, Ordering::AcqRel) {
|
||||
return Err(Error::Err("Restart already in progress".into()));
|
||||
}
|
||||
|
||||
self.shutdown()
|
||||
}
|
||||
|
||||
pub fn shutdown(&self) -> Result<()> {
|
||||
if self.stopping.swap(true, Ordering::AcqRel) {
|
||||
return Err(Error::Err("Shutdown already in progress".into()));
|
||||
|
||||
Reference in new issue
Block a user