feat(playout): change playout working directory
- use working dir for storing files BREAKING CHANGE: the playout working directory changed from '/var/tmp/airtime/pypo/' to '/var/lib/libretime/playout' when running with systemd and the current directory by default.
This commit is contained in:
parent
32bea651f6
commit
12f96f5043
4
install
4
install
|
@ -1052,6 +1052,7 @@ verbose "...Done"
|
|||
|
||||
verbose "\n * Installing playout and liquidsoap..."
|
||||
loudCmd "$pip_cmd install ${AIRTIMEROOT}/playout"
|
||||
mkdir_and_chown "${web_user}:${web_user}" "${LIBRETIME_WORKING_DIR}/playout"
|
||||
loudCmd "mkdir -p /var/log/airtime/{pypo,pypo-liquidsoap} /var/tmp/airtime/pypo/{cache,files,tmp} /var/tmp/airtime/show-recorder/"
|
||||
loudCmd "chown -R ${web_user}:${web_user} /var/log/airtime/{pypo,pypo-liquidsoap} /var/tmp/airtime/pypo/{cache,files,tmp} /var/tmp/airtime/show-recorder/"
|
||||
systemInitInstall libretime-liquidsoap "$web_user"
|
||||
|
@ -1076,8 +1077,7 @@ verbose "...Done"
|
|||
|
||||
verbose "\n * Installing libretime-analyzer..."
|
||||
loudCmd "$pip_cmd install ${AIRTIMEROOT}/analyzer"
|
||||
loudCmd "mkdir -p ${LIBRETIME_WORKING_DIR}/analyzer"
|
||||
loudCmd "chown -R ${web_user}:${web_user} ${LIBRETIME_WORKING_DIR}/analyzer"
|
||||
mkdir_and_chown "${web_user}:${web_user}" "${LIBRETIME_WORKING_DIR}/analyzer"
|
||||
systemInitInstall libretime-analyzer "$web_user"
|
||||
verbose "...Done"
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ After=network-online.target
|
|||
|
||||
[Service]
|
||||
Environment=LIBRETIME_LOG_FILEPATH=/var/log/libretime/playout.log
|
||||
WorkingDirectory=/var/lib/libretime/playout
|
||||
|
||||
ExecStart=/usr/local/bin/libretime-playout
|
||||
User=libretime-pypo
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
from pathlib import Path
|
||||
|
||||
CACHE_DIR = Path.cwd() / "scheduler"
|
||||
RECORD_DIR = Path.cwd() / "recorder"
|
|
@ -24,6 +24,7 @@ from libretime_shared.logging import level_from_name, setup_logger
|
|||
from loguru import logger
|
||||
|
||||
from . import pure
|
||||
from .config import CACHE_DIR, RECORD_DIR
|
||||
from .listenerstat import ListenerStat
|
||||
from .pypofetch import PypoFetch
|
||||
from .pypofile import PypoFile
|
||||
|
@ -35,13 +36,6 @@ from .timeout import ls_timeout
|
|||
|
||||
LIQUIDSOAP_MIN_VERSION = "1.1.1"
|
||||
|
||||
PYPO_HOME = "/var/tmp/airtime/pypo/"
|
||||
|
||||
|
||||
def configure_environment():
|
||||
os.environ["HOME"] = PYPO_HOME
|
||||
os.environ["TERM"] = "xterm"
|
||||
|
||||
|
||||
class Global:
|
||||
def __init__(self, api_client):
|
||||
|
@ -117,13 +111,17 @@ def cli(log_level: str, log_filepath: Optional[Path]):
|
|||
"""
|
||||
setup_logger(level_from_name(log_level), log_filepath)
|
||||
|
||||
configure_environment()
|
||||
|
||||
# loading config file
|
||||
try:
|
||||
config = ConfigObj("/etc/airtime/airtime.conf")
|
||||
except Exception as e:
|
||||
logger.error("Error loading config file: %s", e)
|
||||
|
||||
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("###########################################")
|
||||
|
|
|
@ -2,6 +2,7 @@ import copy
|
|||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
from pathlib import Path
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -17,6 +18,7 @@ from libretime_api_client import version2 as api_client
|
|||
from loguru import logger
|
||||
|
||||
from . import pure
|
||||
from .config import CACHE_DIR
|
||||
from .timeout import ls_timeout
|
||||
|
||||
|
||||
|
@ -52,21 +54,9 @@ class PypoFetch(Thread):
|
|||
|
||||
self.pypo_liquidsoap = pypo_liquidsoap
|
||||
|
||||
self.cache_dir = os.path.join(config["cache_dir"], "scheduler")
|
||||
self.cache_dir = CACHE_DIR
|
||||
logger.debug("Cache dir %s", self.cache_dir)
|
||||
|
||||
try:
|
||||
if not os.path.isdir(dir):
|
||||
"""
|
||||
We get here if path does not exist, or path does exist but
|
||||
is a file. We are not handling the second case, but don't
|
||||
think we actually care about handling it.
|
||||
"""
|
||||
logger.debug("Cache dir does not exist. Creating...")
|
||||
os.makedirs(dir)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
self.schedule_data = []
|
||||
logger.info("PypoFetch: init complete")
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ class PypoFile(Thread):
|
|||
Thread.__init__(self)
|
||||
self.media_queue = schedule_queue
|
||||
self.media = None
|
||||
self.cache_dir = os.path.join(config["cache_dir"], "scheduler")
|
||||
self._config = self.read_config_file(CONFIG_PATH)
|
||||
self.api_client = api_client.AirtimeApiClient()
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ from configobj import ConfigObj
|
|||
from libretime_api_client.version1 import AirtimeApiClient as AirtimeApiClientV1
|
||||
from loguru import logger
|
||||
|
||||
from libretime_playout.config import RECORD_DIR
|
||||
|
||||
|
||||
def api_client():
|
||||
"""
|
||||
|
@ -74,7 +76,7 @@ class ShowRecorder(Thread):
|
|||
else:
|
||||
filetype = "ogg"
|
||||
|
||||
joined_path = os.path.join(config["pypo"]["base_recorded_files"], filename)
|
||||
joined_path = os.path.join(RECORD_DIR, filename)
|
||||
filepath = "%s.%s" % (joined_path, filetype)
|
||||
|
||||
br = config["pypo"]["record_bitrate"]
|
||||
|
|
Loading…
Reference in New Issue