Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def core_bootstrap(configfile=None):
"""
Bootstrap the core machinery without MQTT
"""
# Load configuration file
config = load_configuration(configfile)
# Bootstrap mqttwarn.core
bootstrap(config=config, scriptname='testdrive')
# Load services
services = config.getlist('defaults', 'launch')
load_services(services)
# Launch worker threads to operate on queue
start_workers()
def launch_plugin_standalone(plugin, data):
# Load configuration file
scriptname = os.path.splitext(os.path.basename(sys.argv[0]))[0]
config = load_configuration(name=scriptname)
# Setup logging
setup_logging(config)
logger.info('Running service plugin "{}" with data "{}"'.format(plugin, data))
# Launch service plugin
run_plugin(config=config, name=plugin, data=data)
def run_mqttwarn():
# Script name (without extension) used as last resort fallback for config/logfile names
scriptname = os.path.splitext(os.path.basename(sys.argv[0]))[0]
# Load configuration file
config = load_configuration(name=scriptname)
# Setup logging
setup_logging(config)
logger.info("Starting {}".format(scriptname))
logger.info("Log level is %s" % logging.getLevelName(logger.getEffectiveLevel()))
# Handle signals
signal.signal(signal.SIGTERM, cleanup)
signal.signal(signal.SIGINT, cleanup)
# Bootstrap mqttwarn.core
bootstrap(config=config, scriptname=scriptname)
# Connect to broker and start listening
connect()