Skip to content

Commit

Permalink
🔊 add debug logging to ssh server startup/shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
haliphax committed Apr 10, 2024
1 parent 4ff5af4 commit e27e6d5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions xthulu/cli/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys

# 3rd party
from asyncssh import Error as AsyncSSHError
from asyncssh import Error as AsyncSSHError, SSHAcceptor
from click import group

# local
Expand All @@ -25,19 +25,24 @@ def start():
"""Start SSH server process"""

loop = get_event_loop()
server: SSHAcceptor

def shutdown():
log.info("Shutting down")
log.debug("Closing SSH listener")
server.close()
log.debug("Stopping event loop")
loop.stop()
log.debug("Expiring locks")

for owner in _Locks.locks.copy().keys():
log.debug(f"Expiring locks for {owner}")
expire(owner)

loop.stop()

loop.add_signal_handler(SIGTERM, shutdown)

try:
loop.run_until_complete(start_server())
server = loop.run_until_complete(start_server())
except (OSError, AsyncSSHError) as exc:
sys.exit(f"Error: {exc}")

Expand Down

0 comments on commit e27e6d5

Please sign in to comment.