Got the code rearranged as described in the issue. Figured out how to test by setting the diag device to a non-existent device path. It worked, the web UI stayed up after the diag device open failed, but only for a short while. Figured out it was the fact that the code exits the main function when the diag open fails.
Put the UI and display code back, and instead handled the diag error with a match statement, where if it fails it logs the message, otherwise it continues. This runs the web UI on failure and keeps it running so the user can have all the time in the world to check the logs.
Gonna try to PR the code tomorrow after one last review