def cli(log_level: int, log_filepath: Optional[Path]): """ Run liquidsoap. """ log_level = level_from_name(log_level) setup_logger(log_level, log_filepath) generate_liquidsoap_cfg.run(log_filepath) # check liquidsoap version so we can run a scripts matching the liquidsoap minor version liquidsoap_version = subprocess.check_output( "liquidsoap 'print(liquidsoap.version) shutdown()'", shell=True, universal_newlines=True, )[0:3] script_path = os.path.join(os.path.dirname(__file__), liquidsoap_version, "ls_script.liq") exec_args = [ "/usr/bin/liquidsoap", "libretime-liquidsoap", "--verbose", script_path, ] if log_level.is_debug(): exec_args.append("--debug") logger.debug( f"Liquidsoap {liquidsoap_version} using script: {script_path}") os.execl(*exec_args)
def cli( log_level: str, log_filepath: Optional[Path], config_filepath: Optional[Path], retry_queue_filepath: Path, ): """ Run analyzer. """ setup_logger(level_from_name(log_level), log_filepath) config = Config(filepath=config_filepath) # Start up the StatusReporter process StatusReporter.start_thread(retry_queue_filepath) # Start listening for RabbitMQ messages telling us about newly # uploaded files. This blocks until we receive a shutdown signal. _msg_listener = MessageListener(config.rabbitmq) StatusReporter.stop_thread()
def test_level_from_name_invalid(): with pytest.raises(ValueError): level_from_name("invalid")
def test_level_from_name(name, level_name, level_no): level = level_from_name(name) assert level.name == level_name assert level.no == level_no
def cli(log_level: str, log_filepath: Optional[Path]): """ A gateway between Liquidsoap and the API. """ setup_logger(level_from_name(log_level), log_filepath)
def cli(log_level: str, log_filepath: Optional[Path], config_filepath: Optional[Path]): """ Run playout. """ setup_logger(level_from_name(log_level), log_filepath) config = Config(filepath=config_filepath) try: for dir_path in [CACHE_DIR, RECORD_DIR]: dir_path.mkdir(exist_ok=True) except OSError as exception: logger.error(exception) sys.exit(1) logger.info("###########################################") logger.info("# *** pypo *** #") logger.info("# Liquidsoap Scheduled Playout System #") logger.info("###########################################") # Although all of our calculations are in UTC, it is useful to know what timezone # the local machine is, so that we have a reference for what time the actual # log entries were made logger.info("Timezone: %s" % str(time.tzname)) logger.info("UTC time: %s" % str(datetime.utcnow())) signal.signal(signal.SIGINT, keyboardInterruptHandler) api_client = ApiClient() g = Global(api_client) while not g.selfcheck(): time.sleep(5) success = False while not success: try: api_client.register_component("pypo") success = True except Exception as e: logger.error(str(e)) time.sleep(10) telnet_lock = Lock() liquidsoap_host = config.playout.liquidsoap_host liquidsoap_port = config.playout.liquidsoap_port liquidsoap_startup_test(telnet_lock, liquidsoap_host, liquidsoap_port) pypoFetch_q = Queue() recorder_q = Queue() pypoPush_q = Queue() pypo_liquidsoap = PypoLiquidsoap(telnet_lock, liquidsoap_host, liquidsoap_port) """ This queue is shared between pypo-fetch and pypo-file, where pypo-file is the consumer. Pypo-fetch will send every schedule it gets to pypo-file and pypo will parse this schedule to determine which file has the highest priority, and retrieve it. """ media_q = Queue() # Pass only the configuration sections needed; PypoMessageHandler only needs rabbitmq settings pmh = PypoMessageHandler(pypoFetch_q, recorder_q, config.rabbitmq) pmh.daemon = True pmh.start() pfile = PypoFile(media_q) pfile.daemon = True pfile.start() pf = PypoFetch( pypoFetch_q, pypoPush_q, media_q, telnet_lock, pypo_liquidsoap, config, ) pf.daemon = True pf.start() pp = PypoPush(pypoPush_q, telnet_lock, pypo_liquidsoap, config) pp.daemon = True pp.start() recorder = Recorder(recorder_q, config) recorder.daemon = True recorder.start() stat = ListenerStat(config) stat.daemon = True stat.start() # Just sleep the main thread, instead of blocking on pf.join(). # This allows CTRL-C to work! while True: time.sleep(1)