add server restart support w/ admin command
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
2cb31275f0
commit
c6f4b20e17
5 changed files with 54 additions and 2 deletions
|
@ -1,11 +1,16 @@
|
|||
pub(crate) mod clap;
|
||||
mod mods;
|
||||
mod restart;
|
||||
mod server;
|
||||
mod signal;
|
||||
|
||||
extern crate conduit_core as conduit;
|
||||
|
||||
use std::{cmp, sync::Arc, time::Duration};
|
||||
use std::{
|
||||
cmp,
|
||||
sync::{atomic::Ordering, Arc},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use conduit::{debug_info, error, utils::available_parallelism, Error, Result};
|
||||
use server::Server;
|
||||
|
@ -32,8 +37,13 @@ fn main() -> Result<(), Error> {
|
|||
|
||||
// explicit drop here to trace thread and tls dtors
|
||||
drop(runtime);
|
||||
debug_info!("Exit");
|
||||
|
||||
#[cfg(unix)]
|
||||
if server.server.restarting.load(Ordering::Acquire) {
|
||||
restart::restart();
|
||||
}
|
||||
|
||||
debug_info!("Exit");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
17
src/main/restart.rs
Normal file
17
src/main/restart.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
#![cfg(unix)]
|
||||
|
||||
use std::{env, os::unix::process::CommandExt, process::Command};
|
||||
|
||||
use conduit::{debug, info};
|
||||
|
||||
pub(super) fn restart() -> ! {
|
||||
let exe = env::current_exe().expect("program path must be identified and available");
|
||||
let envs = env::vars();
|
||||
let args = env::args().skip(1);
|
||||
debug!(?exe, ?args, ?envs, "Restart");
|
||||
|
||||
info!("Restart");
|
||||
|
||||
let error = Command::new(exe).args(args).envs(envs).exec();
|
||||
panic!("{error:?}");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue