Skip to content

Commit

Permalink
Merge pull request #940 from changweige/2.1-fix-graceful-exit
Browse files Browse the repository at this point in the history
nydusd: register signal hanlder earlier
  • Loading branch information
jiangliu authored Dec 9, 2022
2 parents e02fd27 + df8a6f5 commit 820b378
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/bin/nydusd/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,6 @@ impl DaemonController {

let daemon = self.daemon.lock().unwrap().take();
if let Some(d) = daemon {
/*
// TODO: fix the behavior
if cfg!(feature = "virtiofs") {
// In case of virtiofs, mechanism to unblock recvmsg() from VMM is lacked.
// Given the fact that we have nothing to clean up, directly exit seems fine.
process::exit(0);
}
*/
if let Err(e) = d.stop() {
error!("failed to stop daemon: {}", e);
}
Expand Down Expand Up @@ -721,6 +713,10 @@ fn main() -> Result<()> {

setup_logging(logging_file, level, rotation_size)?;

// Initialize and run the daemon controller event loop.
nydus_app::signal::register_signal_handler(signal::SIGINT, sig_exit);
nydus_app::signal::register_signal_handler(signal::SIGTERM, sig_exit);

dump_program_info();
handle_rlimit_nofile_option(&args, "rlimit-nofile")?;

Expand Down Expand Up @@ -758,10 +754,6 @@ fn main() -> Result<()> {
let mut api_controller = ApiServerController::new(apisock);
api_controller.start()?;

// Initialize and run the daemon controller event loop.
nydus_app::signal::register_signal_handler(signal::SIGINT, sig_exit);
nydus_app::signal::register_signal_handler(signal::SIGTERM, sig_exit);

// Run the main event loop
if DAEMON_CONTROLLER.is_active() {
DAEMON_CONTROLLER.run_loop();
Expand Down

0 comments on commit 820b378

Please sign in to comment.