raise Exception('db_synchronous_override must be in the range 0-3') HG.no_db_temp_files = result.no_db_temp_files if result.temp_dir is not None: HydrusPaths.SetEnvTempDir(result.temp_dir) HydrusPaths.AddBaseDirToEnvPath() # try: action = ServerController.ProcessStartingAction(db_dir, action) except HydrusExceptions.ShutdownException as e: HydrusData.Print(e) action = 'exit' if action == 'exit': sys.exit(0) except Exception as e: error_trace = traceback.format_exc()
def boot(): try: HG.server_action = ServerController.ProcessStartingAction( db_dir, HG.server_action) except HydrusExceptions.ShutdownException as e: HydrusData.Print(e) HG.server_action = 'exit' if HG.server_action == 'exit': sys.exit(0) controller = None with HydrusLogger.HydrusLogger(db_dir, 'server') as logger: try: if HG.server_action in ('stop', 'restart'): ServerController.ShutdownSiblingInstance(db_dir) if HG.server_action in ('start', 'restart'): HydrusData.Print('Initialising controller\u2026') threading.Thread(target=reactor.run, name='twisted', kwargs={ 'installSignalHandlers': 0 }).start() controller = ServerController.Controller(db_dir) controller.Run() except (HydrusExceptions.DBCredentialsException, HydrusExceptions.ShutdownException) as e: error = str(e) HydrusData.Print(error) except: import traceback error = traceback.format_exc() HydrusData.Print('Hydrus server failed') HydrusData.Print(error) finally: HG.view_shutdown = True HG.model_shutdown = True if controller is not None: controller.pubimmediate('wake_daemons') reactor.callFromThread(reactor.stop) HydrusData.Print('hydrus server shut down')