Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Improve exit cleanup #302

Merged
merged 3 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions ospd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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

Expand Down