Commit d0e738c6 authored by Joel Collins's avatar Joel Collins
Browse files

Load config and plugins at startup

parent 71b5c685
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@ import logging, sys
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)

# Create a dummy microscope object, with no hardware attachments
api_microscope = Microscope(None, None)
openflexurerc = config.load_config()  # Load default user config
api_microscope = Microscope(None, None, config=openflexurerc)
logging.debug("Created an empty microscope in global.")


@@ -66,9 +67,8 @@ for code in default_exceptions:
@app.before_first_request
def attach_microscope():
    # Create the microscope object globally (common to all spawned server threads)
    global api_microscope
    global api_microscope, openflexurerc
    logging.debug("First request made. Populating microscope with hardware...")
    openflexurerc = config.load_config()  # Load default user config

    logging.debug("Creating camera object...")
    api_camera = StreamingCamera(config=openflexurerc)
@@ -81,9 +81,6 @@ def attach_microscope():
        api_stage
    )

    logging.debug("Attaching plugins to microscope...")
    api_microscope.find_plugins()  # Automatically find microscope plugins

    logging.debug("Microscope successfully attached!")