unix: send SIGTERM instead of killing the service (#59)

This commit is contained in:
Ferdinand Schober
2023-12-27 19:56:43 +01:00
committed by GitHub
parent 4b6faea93a
commit e155819542
4 changed files with 40 additions and 24 deletions

View File

@@ -39,6 +39,15 @@ pub fn run() -> Result<()> {
let mut service = start_service()?;
frontend::run_frontend(&config)?;
log::info!("terminating service");
#[cfg(unix)]
{
// on unix we give the service a chance to terminate gracefully
let pid = service.id() as libc::pid_t;
unsafe {
libc::kill(pid, libc::SIGINT);
}
service.wait()?;
}
service.kill()?;
}