Add exit handler
This commit is contained in:
parent
1160849b3e
commit
e940c13019
|
@ -1,4 +1,5 @@
|
||||||
import argparse
|
import argparse
|
||||||
|
import atexit
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import signal
|
import signal
|
||||||
|
@ -37,10 +38,18 @@ def handle_sigint(*_) -> None:
|
||||||
exit_counter += 1
|
exit_counter += 1
|
||||||
|
|
||||||
|
|
||||||
|
def exit_handler(*_) -> None:
|
||||||
|
global adb
|
||||||
|
if adb is not None:
|
||||||
|
with console.status("[cyan]Stopping adb server", spinner="line", spinner_style="white"):
|
||||||
|
adb.server_kill()
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
global adb
|
global adb
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, handle_sigint)
|
signal.signal(signal.SIGINT, handle_sigint)
|
||||||
|
atexit.register(exit_handler)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Linux on Nabu deployer",
|
description="Linux on Nabu deployer",
|
||||||
|
|
Reference in a new issue