diff --git a/CHANGELOG.md b/CHANGELOG.md index 332bd1f8..c7c373c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Make scan_id attribute mandatory for get_scans. [#270](https://github.com/greenbone/ospd/pull/270) - Ignore subsequent SIGINT once inside exit_cleanup(). [#273](https://github.com/greenbone/ospd/pull/273) - Simplify start_scan() [#275](https://github.com/greenbone/ospd/pull/275) +- Make ospd-openvas to shut down gracefully [#302](https://github.com/greenbone/ospd/pull/302) ### Fixed - Fix stop scan. Wait for the scan process to be stopped before delete it from the process table. [#204](https://github.com/greenbone/ospd/pull/204) diff --git a/ospd/main.py b/ospd/main.py index fe7a37de..23276965 100644 --- a/ospd/main.py +++ b/ospd/main.py @@ -72,13 +72,12 @@ def exit_cleanup( signal.signal(signal.SIGINT, signal.SIG_IGN) pidpath = Path(pidfile) - daemon.daemon_exit_cleanup() - if not pidpath.is_file(): return with pidpath.open() as f: if int(f.read()) == os.getpid(): + daemon.daemon_exit_cleanup() LOGGER.info("Shutting-down server ...") server.close() LOGGER.debug("Finishing daemon process") @@ -144,7 +143,9 @@ def main( signal.signal( signal.SIGTERM, partial(exit_cleanup, args.pid_file, server, daemon) ) - + signal.signal( + signal.SIGINT, partial(exit_cleanup, args.pid_file, server, daemon) + ) if not daemon.check(): return 1