Files
hla_framework_bd/bin/start_service.sh
2026-08-27 11:22:02 +02:00

51 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
SVC_NAME=$1
set --
SERVICES_DIR=/sls/bd/hla/${AGEBD_ENV}/services
SVC_NAME_LOWER=${SVC_NAME,,}
SVC_NAME_LOWER_UNDERSCORES="${SVC_NAME_LOWER//-/_}"
SVC_DIR=${SERVICES_DIR}/${SVC_NAME_LOWER}
# gfa_12_epics.sh died on the 16.04.2026 due to required AFS write access
#. /etc/profile.d/gfa_12_epics.sh
#. /sls/bd/exchange/BeamData/user/felix/workarounds/epicsRHEL8.rc # temporary fix
# cas_12_epics.sh can only fall back to the CA gateway when its broadcast-address
# auto-detection fails (e.g. non-accelerator-network hosts) if PSI_GFA_FACILITY is
# set; systemd --user units don't inherit it from an interactive login shell so we need
# to set PSI_GFA_FACILITY=SLS explicitely.
export PSI_GFA_FACILITY=SLS
. /etc/profile.d/cas_12_epics.sh
if [ "${AGEBD_ENV}" = "dev" ]; then
export EPICS_CA_ADDR_LIST="$EPICS_CA_ADDR_LIST 129.129.146.255"
fi
echo "EPICS_CA_ADDR_LIST:"
echo "$EPICS_CA_ADDR_LIST"
# activate conda environment
. /opt/gfa/python-3.10/latest/bin/activate
# TODO: building the .venv should be done in CICD (only when uv.lock changes)
pip install uv
# to run `uv ...`
PATH="${HOME}/.local/bin:${PATH}"
export UV_CACHE_DIR="/var/cache/uv"
export UV_LINK_MODE="copy"
APP_DIR=${SVC_DIR}/current/app
echo "App dir: ${APP_DIR}"
uv venv --project "${APP_DIR}" --allow-existing
# install custom python packages from pyproject.toml / uv.lock
uv sync --frozen --project ${APP_DIR}
# activate .venv, this works in conjunction with the conda environment
source ${APP_DIR}/.venv/bin/activate
exec python -u -B -m agebd_${SVC_NAME_LOWER_UNDERSCORES}.main
# TODO: remove: cicd test 57