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

Add information about interrupted conversion/dist-upgrade to stdout and motd #78

Merged
merged 2 commits into from
Oct 4, 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
20 changes: 16 additions & 4 deletions pleskdistup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,21 @@ def try_lock(lock_file: PathType) -> typing.Generator[bool, None, None]:
log.warn(f"Failed to remove lockfile {lock_file!r}: {ex}")


def exit_signal_handler(signum, frame):
# exit will trigger blocks finalization, so lockfile will be removed
log.info(f"Received signal {signum}, going to exit...")
sys.exit(1)
def create_exit_signal_handler(utility_name: str) -> typing.Callable[[int, typing.Any], None]:
def exit_signal_handler(signum, frame):
# exit will trigger blocks finalization, so lockfile will be removed
log.info(f"Received signal {signum}, going to exit...")
print(f"The dist-upgrade process was stopped by signal {signum}. Please use the `{utility_name} --revert` option before trying again.")

motd.add_finish_ssh_login_message(f"""
The dist-upgrade process was stopped by signal.
Please use the `{utility_name} --revert` option before trying again.
""")
motd.publish_finish_ssh_login_message()

sys.exit(1)

return exit_signal_handler


DESC_MESSAGE = """Use this utility to dist-upgrade your server with Plesk.
Expand Down Expand Up @@ -414,6 +425,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)

Expand Down
Loading