mirror of
https://github.com/TheCommsChannel/TC2-APRS-BBS.git
synced 2025-06-28 15:57:15 -04:00
Implement clean exit
This commit is contained in:
parent
bd51c53c87
commit
f797b5909a
2 changed files with 26 additions and 1 deletions
13
main.py
13
main.py
|
@ -3,6 +3,9 @@ import aprs_comm
|
|||
import threading
|
||||
import time
|
||||
|
||||
import signal
|
||||
import sys
|
||||
|
||||
|
||||
def scheduled_cleanup():
|
||||
"""Periodically run cleanup of expired bulletins."""
|
||||
|
@ -14,6 +17,11 @@ def scheduled_cleanup():
|
|||
print(f"Error during cleanup: {e}")
|
||||
time.sleep(24 * 60 * 60) # Run cleanup every 24 hours
|
||||
|
||||
def signal_handler(signum, frame):
|
||||
print(f"Received signal {signum}. Shutting down...")
|
||||
aprs_comm.shutdown()
|
||||
|
||||
|
||||
def main():
|
||||
banner = """
|
||||
\033[96m
|
||||
|
@ -34,8 +42,13 @@ def main():
|
|||
cleanup_thread = threading.Thread(target=scheduled_cleanup, daemon=True)
|
||||
cleanup_thread.start()
|
||||
|
||||
print("Setting up signal handlers...")
|
||||
signal.signal(signal.SIGINT, signal_handler) # Ctrl+C
|
||||
signal.signal(signal.SIGTERM, signal_handler) # kill command
|
||||
|
||||
print("Starting APRS communications...")
|
||||
aprs_comm.start()
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue