Smarter server teardown procedure
This commit is contained in:
parent
ea253f8085
commit
0f8070b64a
1 changed files with 14 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ from openflexure_microscope.config import USER_CONFIG_DIR
|
|||
|
||||
from openflexure_microscope.api.v1 import blueprints
|
||||
|
||||
import time
|
||||
import atexit
|
||||
import logging
|
||||
import sys
|
||||
|
|
@ -168,17 +169,27 @@ def err_log():
|
|||
def cleanup():
|
||||
global api_microscope
|
||||
logging.debug("App teardown started...")
|
||||
logging.debug("Settling...")
|
||||
time.sleep(0.5)
|
||||
|
||||
# Save config
|
||||
if api_microscope.rc:
|
||||
api_microscope.rc.save(backup=True)
|
||||
logging.debug("Saving config for teardown...")
|
||||
api_microscope.save_config(backup=True)
|
||||
|
||||
logging.debug("Settling...")
|
||||
time.sleep(0.5)
|
||||
|
||||
# Close down the microscope
|
||||
logging.debug("Closing devices...")
|
||||
api_microscope.close()
|
||||
|
||||
logging.debug("Settling...")
|
||||
time.sleep(0.5)
|
||||
|
||||
logging.debug("App teardown complete.")
|
||||
|
||||
|
||||
atexit.register(cleanup)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host='0.0.0.0', port="5000", threaded=True, debug=True, use_reloader=False)
|
||||
app.run(host='0.0.0.0', port="5000", threaded=True, debug=True, use_reloader=False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue