def irc_update_config(manager): global irc_manager, config_hash # Exit if we're not running daemon mode if not manager.is_daemon: return config = manager.config.get('irc') # No config, no connections if not config: logger.debug('No irc connections defined in the config') stop_irc(manager) return if irc_bot is None: logger.error( 'ImportError: irc_bot module not found or version is too old. Shutting down daemon.' ) stop_irc(manager) manager.shutdown(finish_queue=False) return config_hash.setdefault('names', {}) new_config_hash = get_config_hash(config) if config_hash.get('config') == new_config_hash: logger.verbose( 'IRC config has not been changed. Not reloading any connections.') return config_hash['manager'] = new_config_hash if irc_manager is not None and irc_manager.is_alive(): irc_manager.update_config(config) else: irc_manager = IRCConnectionManager(config)
def irc_update_config(manager): global irc_manager, config_hash # Exit if we're not running daemon mode if not manager.is_daemon: return config = manager.config.get('irc') # No config, no connections if not config: log.debug('No irc connections defined in the config') stop_irc(manager) return if irc_bot is None: log.error('ImportError: irc_bot module not found. Shutting down daemon.') stop_irc(manager) manager.shutdown(finish_queue=False) return # TODO this hashing doesn't quite work for nested dicts new_config_hash = hashlib.md5(str(sorted(list(config.items()))).encode('utf-8')).hexdigest() if config_hash == new_config_hash: log.debug('IRC config has not been changed. Not reloading the connections.') return config_hash = new_config_hash # Config for IRC has been removed, shutdown all instances stop_irc(manager) irc_manager = IRCConnectionManager(config)
def irc_update_config(manager): global irc_manager, config_hash # Exit if we're not running daemon mode if not manager.is_daemon: return config = manager.config.get('irc') # No config, no connections if not config: log.debug('No irc connections defined in the config') stop_irc(manager) return if irc_bot is None: log.error( 'ImportError: irc_bot module not found or version is too old. Shutting down daemon.' ) stop_irc(manager) manager.shutdown(finish_queue=False) return config_hash.setdefault('names', {}) new_config_hash = get_config_hash(config) if config_hash.get('config') == new_config_hash: log.verbose('IRC config has not been changed. Not reloading any connections.') return config_hash['manager'] = new_config_hash if irc_manager is not None and irc_manager.is_alive(): irc_manager.update_config(config) else: irc_manager = IRCConnectionManager(config)
def start_connections(self): """ Start all the irc connections. Stop the daemon if there are failures. :return: """ global irc_connections # First we validate the config for all connections including their .tracker files errors = 0 for conn_name, connection in self.config.items(): try: log.info('Starting IRC connection for %s', conn_name) conn = IRCConnection(connection, conn_name) irc_connections[conn_name] = conn except (MissingConfigOption, TrackerFileParseError, TrackerFileError, IOError) as e: log.error(e) errors += 1 if errors: manager.shutdown(finish_queue=False) return # Now we can start for conn_name, connection in irc_connections.items(): connection.thread.start()
def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) from flexget.manager import manager manager.shutdown(finish_queue=False) self.ReportServiceStatus(win32service.SERVICE_STOPPED)