def create(): # "dynamic" module classes ... injector.provide(ImageProcessorInterface, ImageProcessor) injector.provide(FSHardwareControllerInterface, FSHardwareControllerSingleton) injector.provide(FSCalibrationInterface, FSCalibration) injector.provide(FSScanProcessorInterface, FSScanProcessor)
def run(self): self._logger.info("FabScanPi-Server " + str(__version__)) try: injector.provide(FSEventManagerInterface, FSEventManagerSingleton) #injector.provide_instance(FSWebSocketServerInterface, FSWebSocketServer()) injector.provide_instance(ConfigInterface, Config(self.config_file, True)) injector.provide_instance(SettingsInterface, Settings(self.settings_file, True)) # inject "dynamic" classes self.config = injector.get_instance(ConfigInterface) FSScannerFactory.injectScannerType(self.config.scanner_type) self.webserver = FSWebServer() self.webserver.start() self.scanner = FSScanner() self.scanner.start() FSEventManagerSingleton().instance.subscribe( FSEvents.COMMAND, self.on_server_command) while not self.system_exit.kill: time.sleep(0.3) if self.upgrade: self._logger.info("Upgrading FabScanPi Server") self.update_server() self.restart = True if self.restart: self._logger.info("Restarting FabScanPi Server") self.restart_server() self.webserver.kill() self._logger.debug("Waiting for Webserver exit...") self.scanner.kill() self._logger.debug("Waiting for Scanner exit...") self.scanner.join() self._logger.info("FabScan Server Exit. Bye!") os._exit(1) except (KeyboardInterrupt, SystemExit): self._logger.info("FabScan Server Exit. Bye!") sys.exit(0)
def create_services(self): injector.provide(FSEventManagerInterface, FSEventManagerSingleton) injector.provide_instance(ConfigInterface, Config(self.config_file)) injector.provide_instance(SettingsInterface, Settings(self.settings_file)) # inject "dynamic" classes self.config = injector.get_instance(ConfigInterface) FSScannerFactory.injectScannerType(self.config.file.scanner_type) self.webserver = FSWebServer() self.webserver.start() self.scanner = FSScanner() self.scanner.start() self.eventManager = FSEventManagerSingleton() self.eventManager.instance.subscribe(FSEvents.COMMAND, self.on_server_command)