Using the industry best practices, e.g., machine-readable&analyzable logging.
Trying to be as considerate/user-friendly as possible. E.g., display QR Code right in terminal, and even in small 80x25 size windows:
Make every possible effort to be robust and fault-tolerance. E.g., trying to recover from any temporary failures:
Using every possible attempt to stay alive & connected, while making the approach discreet (undetectable from the server end). E.g., stay-alive in debug mode:
Execution
Fault-tolerance execution loop, until no longer able to do hot relogin:
while :; do OWCI_LOG=2 owc-insight ; [ $? -eq 9 ] && break; sleep 5m; done; rm storage.json; echo "Down at `date`", send Down Alert
This has been running for the whole day and is still going strong.