Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't write motd message on receiving signal on reboot #83

Merged
merged 1 commit into from
Oct 9, 2024
Merged
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
13 changes: 10 additions & 3 deletions pleskdistup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ def exit_signal_handler(signum, frame):
return exit_signal_handler


def assign_killing_signals(handler: typing.Callable[[int, typing.Any], None]) -> None:
for signum in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP, signal.SIGABRT):
signal.signal(signum, handler)


DESC_MESSAGE = """Use this utility to dist-upgrade your server with Plesk.

The utility writes a log to the file specified by --log-file. If there are any issues, you can find more information in the log file.
Expand Down Expand Up @@ -425,9 +430,7 @@ def main():
options.help = False

# signals handler initialization
exit_signal_handler = create_exit_signal_handler(util_name)
for signum in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP, signal.SIGABRT):
signal.signal(signum, exit_signal_handler)
assign_killing_signals(create_exit_signal_handler(util_name))

# Configure locale to avoid problems on systems where LANG or LC_CTYPE changed,
# while files on the system still has utf-8 encoding
Expand Down Expand Up @@ -615,6 +618,10 @@ def main():
log.debug(f"Removed the resume file {options.resume_path!r}")
os.unlink(options.completion_flag_path)

# After lock there's no need to manage signals in such a detailed manner
# Simply log the reason for not rebooting
assign_killing_signals(lambda signum, frame: log.info(f"Received signal {signum}, going to exit..."))

if not options.no_reboot and convert_result.reboot_requested:
log.info("Going to reboot the system")
if options.phase is Phase.CONVERT:
Expand Down
Loading